how to insert data
-
Hi Im doing an application in Visual C# 2005, my application can read data from my database but cant save into the database. Heres the code. What am I missing....Pliz Help!!!! private void btnSave_Click(object sender, EventArgs e) { string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source=YAC.mdb"; OleDbConnection conn = new OleDbConnection(strConnection); conn.Open(); string strCommand = "INSERT INTO ClientProfile(Name,Surname,Gender,IdNumber) Values ('" + txtName.Text + "','" + txtSurname.Text + "','" + cbxGender.Text + "','" + txtIdNumber.Text + "')"; OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.InsertCommand = new OleDbCommand(strCommand, conn); (this.yACDataSet.ClientProfile); int t1 = adapter.InsertCommand.ExecuteNonQuery(); conn.Close(); if (t1 > 0) { MessageBox.Show("added successfully!"); } csanda
-
Hi Im doing an application in Visual C# 2005, my application can read data from my database but cant save into the database. Heres the code. What am I missing....Pliz Help!!!! private void btnSave_Click(object sender, EventArgs e) { string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source=YAC.mdb"; OleDbConnection conn = new OleDbConnection(strConnection); conn.Open(); string strCommand = "INSERT INTO ClientProfile(Name,Surname,Gender,IdNumber) Values ('" + txtName.Text + "','" + txtSurname.Text + "','" + cbxGender.Text + "','" + txtIdNumber.Text + "')"; OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.InsertCommand = new OleDbCommand(strCommand, conn); (this.yACDataSet.ClientProfile); int t1 = adapter.InsertCommand.ExecuteNonQuery(); conn.Close(); if (t1 > 0) { MessageBox.Show("added successfully!"); } csanda