I've been working for this for more than an hour
Hope someone helps me.
Here's my code
Don't ask the error cause' there's none.
The problem is it does not Update the records in its database when it's stopped, or run again.
Hope someone helps me.
Here's my code
Code:
Try
Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\LBHdb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
con.Open()
cmd.Connection = con
'cmd.CommandText = "INSERT INTO tblTires(brandname, treadname, size, purchasecost, unitprice) VALUES('" & cboCompanyname.Text & "','" & txtproductname.Text & "','" & txtsize.Text & "' ,'" & txtpurchaseprice.Text & "','" & txtpriceperunit.Text & "' )"
cmd.CommandText = "INSERT INTO tblTires (brandname, treadname, size, purchasecost,unitprice) values(@bN,@tN,@sz,@pc,@up)"
cmd.Parameters.Add("@bN", Data.SqlDbType.Text).Value = cboCompanyname.Text
cmd.Parameters.Add("@tN", Data.SqlDbType.Text).Value = txtproductname.Text
cmd.Parameters.Add("@sz", Data.SqlDbType.Text).Value = txtsize.Text
cmd.Parameters.Add("@pc", Data.SqlDbType.Decimal).Value = txtpurchaseprice.Text
cmd.Parameters.Add("@up", Data.SqlDbType.Decimal).Value = txtpriceperunit.Text
cmd.Connection = con
Dim ds As New DataSet
Dim da As New SqlDataAdapter
Dim sql As String = "SELECT * FROM tblTires "
da.SelectCommand = New SqlCommand(sql, con)
da.InsertCommand = cmd
da.Fill(ds, "tblTires")
da.Update(ds, "tblTires")
cmd.ExecuteNonQuery()
con.Close()
MsgBox("Tire Information has been added", MsgBoxStyle.Information, "Success")
cleartxtboxt()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
Don't ask the error cause' there's none.
The problem is it does not Update the records in its database when it's stopped, or run again.
Comment