برنامه نویسی

string conStr;

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

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

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

            con.Open(); //دستور برای بازیابی تمام فیلدهای جدول

            strSql = "INSERT INTO Table1(" + "t," + "shs," + "k," + "sh," + "a," + "be," + "bs)VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.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("سند شما با موقثیت ذحیره شد");   

 

+ نوشته شده در  دوشنبه سی ام دی ۱۳۸۷ساعت 22:13  توسط ابراری |