public void FindPathOfBuildingDB()
{
try
{
BuildingSelected.Clear();
string databasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
// string databaseFile = databasePath + @"\db_psychrometric_project.s3db";
// string connString = @"Data Source=" + databaseFile + ";Version=3;";
string path = databasePath; //@"C:\Folder1\Folder2\Folder3\Folder4";
string newPath = Path.GetFullPath(Path.Combine(path, @"..\"));
// string againDbPath = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + newPath + @"Database\T3000.db";
string againDbPath = @"Data Source=" + newPath + @"Database\T3000.db";
// MessageBox.Show("New path : " + againDbPath);
// bool returnValue = false;
//string latValue = "";
using (OleDbConnection connection = new OleDbConnection(againDbPath))
{
connection.Open();
OleDbDataReader reader = null;
string queryString = "SELECT * from Building WHERE Default_SubBuilding = 1 ";//-1 or True can be used//New changed to 1 value
OleDbCommand command = new OleDbCommand(queryString, connection);
reader = command.ExecuteReader();
while (reader.Read())
{
BuildingSelected.Add(new SelectedBuildingDatatype
{
Main_BuildingName = reader["Main_BuildingName"].ToString(),
Building_Name = reader["Building_Name"].ToString(),
Building_Path = reader["Building_Path"].ToString()
});
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//MessageBox.Show("count = " + BuildingSelected.Count);
}