By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,501 Members | 1,678 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,501 IT Pros & Developers. It's quick & easy.

insert in database

P: 41
i m using vs2005.i have gridview on displays datatable values.i have insert button on page.i want to insert data in textbox into database.i m using disconnected archi.

protected void BtnInsert_Click(object sender, EventArgs e)
SqlDataAdapter adap= new SqlDataAdapter("select * from info", con2);
adap.MissingSchemaAction = MissingSchemaAction.AddWithKey;
ds= new DataSet();
DataRow drow = ds.Tables["t"].NewRow();
drow[0] = TextBox1.Text;
drow[1] = TextBox2.Text;
drow[2] = TextBox3.Text;
drow[3] = TextBox4.Text;

i m getting error on this:
Update requires a valid InsertCommand when passed DataRow collection with new rows.

can anyone tell me code to insert data in database using dataadpter,plz tell
thnx in advance
Apr 1 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 4,871
Your insert statement looks remarkably like a select query. Suggest you learn the basics, there are many online tutorials - try google.

Apr 1 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.