V
valamas
C# .NET 2.0
whats wrong with my code?
I get an error on the second line saying "NullReferenceException was
unhandled by user code" - "Object reference not set to an instance of
an object."
01 string sql = "select * from myTable";
02 DataTable dtStructure = Database.ExecuteDataTable(sql);
here is my function
public DataTable ExecuteDataTable(string sql)
{
// Conn and Cmd are publics
Cmd.CommandType = CommandType.Text;
Cmd.CommandText = sql;
SqlDataAdapter sqlAdapter = new SqlDataAdapter(Cmd);
DataTable dt = new DataTable("myTable");
sqlAdapter.Fill(dt);
//close our connection
Conn.Close();
//return our DataTable
return dt;
}
whats wrong with my code?
I get an error on the second line saying "NullReferenceException was
unhandled by user code" - "Object reference not set to an instance of
an object."
01 string sql = "select * from myTable";
02 DataTable dtStructure = Database.ExecuteDataTable(sql);
here is my function
public DataTable ExecuteDataTable(string sql)
{
// Conn and Cmd are publics
Cmd.CommandType = CommandType.Text;
Cmd.CommandText = sql;
SqlDataAdapter sqlAdapter = new SqlDataAdapter(Cmd);
DataTable dt = new DataTable("myTable");
sqlAdapter.Fill(dt);
//close our connection
Conn.Close();
//return our DataTable
return dt;
}