JOIN DEVPPL

It looks like you are new here. If you want to get involved, click on Join below!



VB amature - Program crashing with if statements


R

keyboard_arrow_up
0
keyboard_arrow_down


First Post Mark as Spam richardreynolds
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()
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()
cmd.ExecuteNonQuery()
con1.Close()
MessageBox.Show("Your record has been successfully added", "Adding Records", MessageBoxButtons.OK, MessageBoxIcon.Information)
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






JOIN DEVPPL

It looks like you are new here. If you want to get involved, click on Join below!




MENU
Advertising