search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

loadResources error

Asked by Dragan
12 years ago.

Why get error- Unable to open the database file on line da.Fill(dt);?

private void loadResources()
{
DayPilotScheduler1.Resources.Clear();

string roomFilter = "0";
if (DayPilotScheduler1.ClientState["filter"] != null)
{
roomFilter = (string)DayPilotScheduler1.ClientState["filter"]["room"];
}
SQLiteConnection con = new SQLiteConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=Korisnik;Integrated Security=True");
SQLiteDataAdapter da = new SQLiteDataAdapter("SELECT [id], [name], [beds], [bath] FROM [RoomDetails] WHERE beds = @beds or @beds = '0'", con);
da.SelectCommand.Parameters.AddWithValue("beds", roomFilter);
DataTable dt = new DataTable();
da.Fill(dt);

foreach (DataRow r in dt.Rows)
{
string name = (string)r["name"];
string id = (string)r["id"];
string bath = (string)r["bath"];
int beds = Convert.ToInt32(r["beds"]);
string bedsFormatted = (beds == 1) ? "1 bed" : String.Format("{0} beds", beds);

Resource res = new Resource(name, id);
res.Columns.Add(new ResourceColumn(bedsFormatted));
res.Columns.Add(new ResourceColumn(bath));

DayPilotScheduler1.Resources.Add(res);
}

}

Answer posted by Dan Letecky [DayPilot]
12 years ago.

You are trying to connect to Microsoft SQL Server using SQLite ADO.NET adapter.

You need to replace "SQLite*" with "Sql*".

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.