I am having a problem inserting data into a database. I had it working yesterday and when I can in today it would not work. It works sometimes when i click the add button twice real quick but does not work if I only click it once or twice slowly. Does anyone see anything in my code that I could change to make it work on one click all the time...I really need help on this..I have to have it working by the end of the day today...Any help is appreciated more than you may every know.
Private Sub cmdadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdadd.Click
Dim strCommandText As String
strCommandText = "INSERT INTO InvoiceHistory (InvoiceDate,InvoiceNumber,LineSEQNo,CustomerNumber,ItemNumber,ProductLine,QuantityShipped,LastUnitPrice,DiscountP, PONumber) VALUES ("
strCommandText += "'" + lbldatedisp.Text + "',"
strCommandText += txtinvnum.Text + ","
strCommandText += "'" + txtrefnum.Text + "',"
strCommandText += "'" + lblcustdisp.Text + "',"
strCommandText += "'" + cbotype.Items(cbotype.SelectedIndex) + "',"
strCommandText += "'" + Mid$(cboprodln.Items(cboprodln.SelectedIndex), Len(cboprodln.Items(cboprodln.SelectedIndex)) - 3) + "',"
strCommandText += "1," ' QuantityShipped
strCommandText += txtdeduct.Text + ","
strCommandText += "'0'," ' Discount
strCommandText += "'" + lblponumber.Text + "')"
cmdAddInventory.CommandText = strCommandText
Try
OleDbConnection1.Open()
cmdaddinventory.ExecuteNonQuery()
Catch Ex As OleDbException
System.Diagnostics.Debug.Write(Ex.Message)
End Try
OleDbConnection1.Close()
cmdfind_Click(sender, e)
cmdclear_Click(sender, e)
End Sub
Private Sub cmdadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdadd.Click
Dim strCommandText As String
strCommandText = "INSERT INTO InvoiceHistory (InvoiceDate,InvoiceNumber,LineSEQNo,CustomerNumber,ItemNumber,ProductLine,QuantityShipped,LastUnitPrice,DiscountP, PONumber) VALUES ("
strCommandText += "'" + lbldatedisp.Text + "',"
strCommandText += txtinvnum.Text + ","
strCommandText += "'" + txtrefnum.Text + "',"
strCommandText += "'" + lblcustdisp.Text + "',"
strCommandText += "'" + cbotype.Items(cbotype.SelectedIndex) + "',"
strCommandText += "'" + Mid$(cboprodln.Items(cboprodln.SelectedIndex), Len(cboprodln.Items(cboprodln.SelectedIndex)) - 3) + "',"
strCommandText += "1," ' QuantityShipped
strCommandText += txtdeduct.Text + ","
strCommandText += "'0'," ' Discount
strCommandText += "'" + lblponumber.Text + "')"
cmdAddInventory.CommandText = strCommandText
Try
OleDbConnection1.Open()
cmdaddinventory.ExecuteNonQuery()
Catch Ex As OleDbException
System.Diagnostics.Debug.Write(Ex.Message)
End Try
OleDbConnection1.Close()
cmdfind_Click(sender, e)
cmdclear_Click(sender, e)
End Sub