Page 1 of 1

EntLib 2.0 Problem.

Posted: Tue 05 Sep 2006 04:07
by scott.pedersen
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.

Posted: Tue 05 Sep 2006 08:22
by Alexey
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.

Posted: Wed 06 Sep 2006 01:46
by scott.pedersen
Hi,

I have fixed the problem. It wasn't anything to do with the AddInParameter method.

Cheers,

Scott.

Posted: Wed 06 Sep 2006 05:52
by Alexey
OK, i see.