Value cannot be null.Parameter name: key when databind in ASP.NET

Posted by Yongwei Xing on Stack Overflow See other posts from Stack Overflow or by Yongwei Xing
Published on 2010-04-08T05:01:50Z Indexed on 2010/04/08 5:03 UTC
Read the original article Hit count: 226

Filed under:
|
|

Hi all I am triing to bind the data to a listbox from sql server then got the error "Value cannot be null.Parameter name: key"

sqlCommand = "SELECT [Country] FROM [tbl_LookupCountry] where [Country] IS NOT NULL";
SqlConnection sqlConCountry = new SqlConnection(connectString);
SqlCommand sqlCommCountry = new SqlCommand();
sqlCommCountry.Connection = sqlConCountry;
sqlCommCountry.CommandType = System.Data.CommandType.Text;
sqlCommCountry.CommandText = sqlCommand;
sqlCommCountry.CommandTimeout = 300;
sqlConCountry.Open();
reader = sqlCommCountry.ExecuteReader();
ddlCountry.DataSource = reader;
ddlCountry.DataBind();
sqlConCountry.Close();

Does anyone meet this problem before?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about sql-server