![]() |
![]() |
|
| برنامه نویسی |
|
private void button1_Click(object sender, EventArgs e)
{ string connectionString;connectionString = "Provider = microsoft.jet.OLEDB.4.0;" + "Data Source = c:\\Users\\hossein\\db1.mdb"; OleDbConnection connection = new OleDbConnection(connectionString); // The insertSQL string contains a SQL statement that // inserts a new row in the source table. string insertSQL;insertSQL = "INSERT INTO shakhsi("+ "shomareh_meli," + "name," + "last_name," + "name_father," + "tarikh_tavalod," + "telephon," + "mobile," + "address)VALUES('"+ textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "')"; OleDbCommand command = new OleDbCommand(insertSQL); // Set the Connection to the new OleDbConnection.command.Connection = connection; // Open the connection and execute the insert command. try{ connection.Open(); command.ExecuteNonQuery(); } catch (Exception ex){ Console.WriteLine(ex.Message);} // The connection is automatically closed when the // code exits the using block.} private void button5_Click(object sender, EventArgs e){ string connectionString;connectionString = "Provider = microsoft.jet.OLEDB.4.0;" + "Data Source = c:\\Users\\hossein\\db1.mdb"; OleDbConnection connection = new OleDbConnection(connectionString); string insertSQL;insertSQL = "DELETE from shakhsi where shomareh_meli="+textBox1.Text; OleDbCommand command = new OleDbCommand(insertSQL);command.Connection = connection; try{ connection.Open(); command.ExecuteNonQuery(); } catch (Exception ex){ Console.WriteLine(ex.Message);} } private void button6_Click(object sender, EventArgs e){ Binding currentBinding; DataSet employeesTable = new DataSet(); OleDbConnection sc; OleDbDataAdapter dataConnect; try{ sc = new OleDbConnection("Provider = microsoft.jet.OLEDB.4.0;" + "Data Source = c:\\Users\\hossein\\db1.mdb");} catch (Exception ex){ MessageBox.Show(ex.Message); return;} dataConnect = new OleDbDataAdapter("SELECT * FROM shakhsi where shomareh_meli="+textBox1.Text, sc);dataConnect.Fill(employeesTable, "shakhsi"); try{ currentBinding = new Binding("Text", employeesTable, "shakhsi.name");textBox2.DataBindings.Add(currentBinding); currentBinding = new Binding("Text", employeesTable, "shakhsi.last_name");textBox3.DataBindings.Add(currentBinding); currentBinding = new Binding("Text", employeesTable, "shakhsi.name_father");textBox4.DataBindings.Add(currentBinding); currentBinding = new Binding("Text", employeesTable, "shakhsi.tarikh_tavalod");textBox6.DataBindings.Add(currentBinding); currentBinding = new Binding("Text", employeesTable, "shakhsi.telephon");textBox7.DataBindings.Add(currentBinding); currentBinding = new Binding("Text", employeesTable, "shakhsi.mobile");textBox8.DataBindings.Add(currentBinding); currentBinding = new Binding("Text", employeesTable, "shakhsi.address");textBox9.DataBindings.Add(currentBinding); } catch (Exception ex){ MessageBox.Show(ex.Message); return;} } private void button7_Click(object sender, EventArgs e){ OleDbConnection connection = new OleDbConnection("Provider = microsoft.jet.OLEDB.4.0;" + "Data Source = c:\\Users\\hossein\\db1.mdb"); string queryString = "UPDATE shakhsi SET shomareh_meli='" + textBox1.Text + "',name='" + textBox2.Text + "',last_name='" + textBox3.Text + "',name_father='" + textBox4.Text + "',tarikh_tavalod='" + textBox6.Text + "',telephon='" + textBox7.Text + "',mobile='" + textBox8.Text + "',address='" + textBox9.Text + "'WHERE shomareh_meli=" + textBox1.Text; OleDbCommand command = new OleDbCommand(queryString, connection);connection.Open(); command.ExecuteReader(); connection.Close(); } } |
|
+ نوشته شده در
دوشنبه دوازدهم مرداد ۱۳۸۸ساعت 12:21 توسط ابراری |
|
|
صفحه نخست پست الکترونیک آرشیو عناوین مطالب وبلاگ |
| درباره وبلاگ |
|
| پیوندهای روزانه |
|
جديدترين هاي هک انجمن دانشجویان مهندسی کامپیوتر لارستان دانشگاه آزاد اسلامی واحد لارستان رشته کامپیوتر یاس نقره ای برنامه نویسی آرشیو پیوندهای روزانه |
| آرشیو موضوعی |
|
برق انیمیشن عمران اسمبلی زبان c زبان c# |
| پیوندها |
|
مهندسی عمران لارستان انجمن معماران جوان لینک دونی لاریها برنامه نویسی موبایل |