Friday, January 25, 2013 6:09 PM
yesterday i read a pdf of .net downloaded from google in which it is mentioned that DataAdapter can only be used to execute select sqlcommand we cant use it for insert,update, delete....is it correct???
but i created a sample windows application using ado disconnected architecture using dataadapter for insert and sqlcommandbuilder to store data in database...it executed successfully i didnt open and close connection
please suggest me a correct concept..is that pdf statement is correct or wrong...
- Moved by litdevMicrosoft Community Contributor Friday, January 25, 2013 6:38 PM
Friday, January 25, 2013 8:07 PM
What pdf document are you referring to?
DataAdapter can be used to
1. fill datasets using the selectcommand and then closing connection to the database. This way you have bulk data without an open connection to the DB.
2. You can then operate on the data in the dataset in memory without having to connect to the db.
3. When you are ready to update the data back, you can use the data adapter again, provided you have defined the update / insert / delete commands as well.
Check the links
- Marked As Answer by ben den Saturday, January 26, 2013 4:22 PM
Saturday, January 26, 2013 5:41 PM
Thanks for reply
but here is a code that i wrote which is executing successful but i have doubt that if i code it in an application that could cause any issue???...the code is here
public partial class Form1 : Form
private void button1_Click(object sender, EventArgs e)
SqlConnection con = new SqlConnection("data source=.\\sqlexpress;integrated security=true;database=emp");
SqlDataAdapter da = new SqlDataAdapter("insert into emp values(" + textBox1.Text + ",'" + textBox2.Text + "'," + textBox3.Text + ")", con);
DataSet ds = new DataSet();
SqlCommandBuilder cbd = new SqlCommandBuilder(da);