Google Answers Logo
View Question
 
Q: C# .NET 2.0 NullReferenceException ( No Answer,   0 Comments )
Question  
Subject: C# .NET 2.0 NullReferenceException
Category: Computers > Programming
Asked by: valamas-ga
List Price: $2.00
Posted: 01 Aug 2005 20:21 PDT
Expires: 01 Aug 2005 21:07 PDT
Question ID: 550650
C# .NET 2.0
whats wrong with my code please?
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 = MyDatabase.ExecuteDataTable(sql);


here is my function in another class, DAL.Database
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;
}
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy