Hi everybody,
I tried to developed a windows application which is works with SQL Server to manipulate data. The problem is when I tried to insert a record to the db it doesn't work, I mean it doesn't give any error but doesn't insert any data in the ql server.
here is my code:
waiting ur reply
Thank you.
I tried to developed a windows application which is works with SQL Server to manipulate data. The problem is when I tried to insert a record to the db it doesn't work, I mean it doesn't give any error but doesn't insert any data in the ql server.
here is my code:
VB.NET:
PrivateSub SaveBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveBtn.Click
'This is a call to updateRecord Fuction
Me.UpdateRecord("INSERT INTO customers(SN,customerid,customername,companyname,companyaddress,phone,fax)VALUES(" & number & ",'" & customeridtxt.Text & "','" & customernametxt.Text & "','" & companytxt.Text & "','" & addresstxt.Text & "','" & phonetxt.Text & "','" & faxtxt.Text & "');")
EndSub
'Here is the UpdateRecord Function
PublicFunction UpdateRecord(ByVal querystr AsString)
Dim updatecmd AsNew SqlCommand
Dim con As SqlConnection = New SqlConnection(g.GetCon)
Dim da AsNew SqlDataAdapter
Try
con.Open()
Catch ex As Exception
MsgBox(ex.Message)
EndTry
Try
updatecmd.Connection = con
updatecmd.CommandText = querystr
updatecmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
EndTry
MsgBox("Information has been saved successfully", MsgBoxStyle.Information, "Confirmation")
con.Close()
ReturnTrue
EndFunction
waiting ur reply
Thank you.
Last edited by a moderator: