p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > C# and C > C# 2005 > BOOK: Beginning Visual C# 2005
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Visual C# 2005
This is the forum to discuss the Wrox book Beginning Visual C# 2005 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, Eric White; ISBN: 9780764578472

Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2005 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 5th, 2009, 07:19 AM
Authorized User
Points: 60, Level: 1
Points: 60, Level: 1 Points: 60, Level: 1 Points: 60, Level: 1
Activity: 5%
Activity: 5% Activity: 5% Activity: 5%
 
Join Date: Mar 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy c# and SQL query

I am working in Asp.net c# platform. I have created a database and now by using c# I want to insert data through textboxes in the database.
The code I have written is
SqlConnection con = newSqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirecto ry|\\fieldstaff.mdf;Integrated Security=True;User Instance=True");
con.Open();
DataSet ds = newDataSet();
DataRow dRow = ds.Tables["dairy"].NewRow();
dRow[0] = textBox8.Text;
dRow[1] = textBox9.Text;
dRow[2] = textBox10.Text;
dRow[3] = textBox11.Text;
dRow[4] = textBox12.Text;
dRow[5] = textBox13.Text;
dRow[6] = textBox14.Text;
ds.Tables[
"dairy"].Rows.Add(dRow);
SqlDataAdapter da = newSqlDataAdapter();
da.Update(ds,
"dairy");
MessageBox.Show("1 row is added");
con.Close();

but I am getting the error "Object reference not set to an instance of an object" at "DataRow dRow = ds.Tables["dairy"].NewRow();" this point. pl. explain me the reason for the same.

Regards,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sql query i need seearam MySQL 7 November 30th, 2008 03:14 AM
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
SQL Query mcinar SQL Language 2 March 1st, 2005 10:16 PM
SQL Query help ruthless Classic ASP Basics 1 December 21st, 2004 06:06 AM
SQL QUERY !!! joseph007 ASP CDO 2 October 9th, 2004 01:22 PM



All times are GMT -4. The time now is 07:46 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc