Hi,
I have the following code that is used to populate a listbox, and works fine -
Database database = DatabaseFactory.CreateDatabase(Resources.Database);
string sqlCommand = "Select Site_Name, Site_Code From Risk_Management_Database.Rmd_Sites_Vw";
DbCommand dbCommand = database.GetSqlStringCommand(sqlCommand);
DataSet dataSet = new DataSet();
database.LoadDataSet(dbCommand, dataSet, "Rmd_Sites_Vw");
site.DisplayMember = "Site_Name";
site.ValueMember = "Site_Code";
site.DataSource = dataSet.Tables["Rmd_Sites_Vw"]
Now I want to return rows that only meet a particular company group, so I have changed the code to the following -
Database database = DatabaseFactory.CreateDatabase(Resources.Database);
string sqlCommand = "Select Site_Name, Site_Code From Risk_Management_Database.Rmd_Sites_Vw Where Company = :CompanyGroup";
DbCommand dbCommand = database.GetSqlStringCommand(sqlCommand);
database.AddInParameter(dbCommand, "CompanyGroup", DbType.String, companyGroup);
DataSet dataSet = new DataSet();
database.LoadDataSet(dbCommand, dataSet, "Rmd_Sites_Vw");
site.DisplayMember = "Site_Name";
site.ValueMember = "Site_Code";
site.DataSource = dataSet.Tables["Rmd_Sites_Vw"];
Now no rows are returned. I can trace the execution and no errors seem to occur, I just don't think the sql command is using the parameter value to filter the result set.
Any help on this issue would be appreciated.
Cheers,
Scott.
EntLib 2.0 Problem.
-
- Posts: 21
- Joined: Tue 06 Jun 2006 03:14
- Location: Auckland, New Zealand
Please send us your project to reproduce the problem. It is desirable to use 'scott' schema objects, otherwise include definition of your own database objects. Do not use third party components. Use e-mail address provided in the Readme file.
Last edited by Alexey on Mon 27 Nov 2006 08:23, edited 1 time in total.
-
- Posts: 21
- Joined: Tue 06 Jun 2006 03:14
- Location: Auckland, New Zealand