Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > BOOK: Beginning Visual C# 2005
Password Reminder
| FAQ | Members List | 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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 5th, 2009, 07:19 AM
Authorized User
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");
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;
SqlDataAdapter da = newSqlDataAdapter();
MessageBox.Show("1 row is added");

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.

Reply With Quote

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 08:07 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.