TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sarah Nel
NA
19
0
Populate DataTable
Apr 9 2010 3:49 AM
Hi everyone, I'm having trouble populating a DataTable with a database.
[code]
public DataTable GetData()
{
string connectionString =
System.Web.HttpContext.Current.Application["solarsearch_dbConnectionString"].ToString();
SqlConnection commandString =
new SqlConnection(connectionString);
commandString.Open();
string SQL = "select * from enquiry";
SqlCommand objCommand = new SqlCommand(SQL, commandString);
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet DS = new DataSet();
adapter.SelectCommand = objCommand;
adapter.Fill(DS);
DataTable dt = DS.Tables[0];
return dt;
}
[/code]
When I execute the code I get the error by
[code]
string connectionString =
System.Web.HttpContext.Current.Application["solarsearch_dbConnectionString"].ToString();
[/code]
saying Object reference not set to an instance of an object.
Any help please.
Reply
Answers (
1
)
Debugging with external files and alternate load methods
Visual Basic