برنامه نویسی

string conStr;

string strSql; //ارتباط با پایگاه داده ها

conStr = "provider = microsoft.jet.OLEDB.4.0;" + "Data Source =d:\\db1.mdb";

OleDbConnection con = new OleDbConnection(conStr);//باز کزدن اتصال

con.Open();

//strSql = "select * from table1 where (shs='" + textBox2.Text + "')";//برای اعمال تغییرات یک نمونه می سازیم

strSql = "Update Table1 Set shs='" + textBox2.Text + "',t='" + textBox1.Text + "',k='" + textBox3.Text + "',sh='" + textBox4.Text + "',a='" + textBox5.Text + "',be='" + textBox6.Text + "',bs='" + textBox7.Text + "' where (shs='" + textBox2.Text + "')";

OleDbDataAdapter da = new OleDbDataAdapter(strSql, con);

DataSet ds = new DataSet();//اعمال دستور مورد نظر در پایگاه داده ها

da.Fill(ds, "Table1");

con.Close();

textBox1.Text = "";

textBox2.Text = "";

textBox3.Text = "";

textBox4.Text = "";

textBox5.Text = "";

textBox6.Text = "";

textBox7.Text = "";

MessageBox.Show("سند مورد نظر اصلاح شد");

+ نوشته شده در  شنبه پنجم بهمن ۱۳۸۷ساعت 14:37  توسط ابراری |