G
Guest
Hi All
I am using .NET Framework version 1.0.3705 to build a website.
Now i have made a webform and on that i have added a dropdown to the page
I bind this listbox to a datareader .
This does not happenm , i have no clue what the problem is
I am attaching the error
<font color='red' >
System.Web.HttpException: DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a property with the name Davolio. at System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) at System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) at System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) at System.Web.UI.Control.DataBind() at TestApp.WebForm1.getEmpDetails() in c:\inetpub\wwwroot\testapp\webform1.aspx.cs:line 67
</font>
I am attaching the code too!
I have made the connection to the Northwind database , this is easilt available
Please advise what is going wrong if there is a KB article for the same?
<code>
private int getEmpDetails()
{
SqlConnection oSQLConn = new SqlConnection("Password=New1234;Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=IND-SPZ4D2K0319");
SqlCommand oSQLCmd;
SqlDataReader oSQLDataRead;
try
{ oSQLConn.Open();
oSQLCmd = new SqlCommand("select * from employees",oSQLConn);
oSQLCmd.CommandType = CommandType.Text;
oSQLDataRead = oSQLCmd.ExecuteReader(CommandBehavior.CloseConnection);
if(oSQLDataRead.Read())
{
//string strName = oSQLDataRead.GetValue(1).ToString() + " " + oSQLDataRead.GetValue(2).ToString();
//ddl01.Items.Add(strName);
ddl01.DataTextField = oSQLDataRead.GetValue(1).ToString();
//ddl01.DataValueField = oSQLDataRead.GetValue(1).ToString();
ddl01.DataSource = oSQLDataRead;
ddl01.DataBind();
}
return 1;
}
catch(Exception ex)
{
Response.Write(ex.ToString());
return -1;
}
}
</code>
I am using .NET Framework version 1.0.3705 to build a website.
Now i have made a webform and on that i have added a dropdown to the page
I bind this listbox to a datareader .
This does not happenm , i have no clue what the problem is
I am attaching the error
<font color='red' >
System.Web.HttpException: DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a property with the name Davolio. at System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) at System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) at System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) at System.Web.UI.Control.DataBind() at TestApp.WebForm1.getEmpDetails() in c:\inetpub\wwwroot\testapp\webform1.aspx.cs:line 67
</font>
I am attaching the code too!
I have made the connection to the Northwind database , this is easilt available
Please advise what is going wrong if there is a KB article for the same?
<code>
private int getEmpDetails()
{
SqlConnection oSQLConn = new SqlConnection("Password=New1234;Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=IND-SPZ4D2K0319");
SqlCommand oSQLCmd;
SqlDataReader oSQLDataRead;
try
{ oSQLConn.Open();
oSQLCmd = new SqlCommand("select * from employees",oSQLConn);
oSQLCmd.CommandType = CommandType.Text;
oSQLDataRead = oSQLCmd.ExecuteReader(CommandBehavior.CloseConnection);
if(oSQLDataRead.Read())
{
//string strName = oSQLDataRead.GetValue(1).ToString() + " " + oSQLDataRead.GetValue(2).ToString();
//ddl01.Items.Add(strName);
ddl01.DataTextField = oSQLDataRead.GetValue(1).ToString();
//ddl01.DataValueField = oSQLDataRead.GetValue(1).ToString();
ddl01.DataSource = oSQLDataRead;
ddl01.DataBind();
}
return 1;
}
catch(Exception ex)
{
Response.Write(ex.ToString());
return -1;
}
}
</code>