Mark as Spam
Posts: 1 - Registered: 2013-05-07 20:02:50
Hi, I am creating a program for a college assignment that has to link to a database, add, find values etc. I have a second form for adding the records which was working before I put if statements to if the value in the text box was blank, have a message box showing saying to re-enter the values. Here is the code that was working before if statements.
cmd = New OleDbCommand() Seems to crash at cmd.ExecuteNonQuery(). I have if statement for each text box under the add button along with the code which is above. Any advise on why this is happening would be greatly appreciated. Thanks
cmd.CommandText = "INSERT into customers (Title, Surname, First_Name, Initials, Street, Town, County, Home_Phone, Work_Phone,sales,framing,restoration,tapestry,exhibition,business,business_name) VALUES ('" & txtCusTitle.Text & "','" & txtSrname.Text & "','" & txtFrstNme.Text & "','" & txtInitials.Text & "','" & txtStrt.Text & "','" & txtTwn.Text & "','" & txtCnty.Text & "','" & txtHmeNo.Text & "','" & txtWrkNo.Text & "'," & chkSleCst.Checked & "," & chkFrmeCus.Checked & "," & chkResCus.Checked & "," & chkTapCus.Checked & "," & chkExhCus.Checked & "," & chkBusCus.Checked & ", '" & txtBusNme.Text & "')"
cmd.Connection = con1
If con1.State = ConnectionState.Closed Then con1.Open()
MessageBox.Show("Your record has been successfully added", "Adding Records", MessageBoxButtons.OK, MessageBoxIcon.Information)