I am getting the below exception when I run my ASP.NET/C#/SQL project on an XP box:
System.Web.HttpException was unhandled by user code
Message="A field or property with the name 'DisplaySchemaTables()' was not found on the selected data source."
Source="System.Web" ...
Can u advise me on what the problem might be? Here is the code causing this. The exception happens on the DataBind():
protected void Load_GridData()
{
GridView1.DataSource = ADONET_methods.DisplaySchemaTables();
GridView1.DataBind();
}
ADONET_methods.cs file:
public static SqlDataReader DisplaySchemaTables()
{
SqlDataReader dr = null;
SqlCommand cmd = null;
SqlConnection conn2 = null;
string SchemaName = "Person";
string connString = "Data Source=.;AttachDbFilename=\"C:\\Program Files\\Microsoft...;Catalog=AdventureWorks;Integrated Security=true;Connect Timeout=30;User Instance=False";
string errorMsg;
try
{
conn2 = new SqlConnection(connString);
cmd = conn2.CreateCommand();
cmd.CommandText = "dbo.getTableNames";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn2;
cmd.Parameters.Add(new SqlParameter("@SchemaName", SchemaName));
conn2.Open();
dr = cmd.ExecuteReader();
}
catch (Exception ex)
{
errorMsg = ex.Message;
}
return dr;
}