hi all I'm new in vb.net and I would like to get some help in something
I'm developing a database application with vb 2008 and my database is MS access 2007 but every time I insert some records , they gone after a few moments . When I insert them I go to the database and I find them there but when I run the program for the second time I don't find them
this is the code
please any advice will be good
I'm developing a database application with vb 2008 and my database is MS access 2007 but every time I insert some records , they gone after a few moments . When I insert them I go to the database and I find them there but when I run the program for the second time I don't find them
this is the code
VB.NET:
Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\smaa.accdb"
Dim dbconnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "INSERT INTO ncustomers (ID, custname , dat , sertype , amount , duration , paytype , phone , email) VALUES (" & txtid.Text & ", '" & txtname.Text & "' ,' " & txtdate.Text & " ', '" & txtst.Text & "' ,' " & txtamount.Text & " ', '" & txtdu.Text & "' ,' " & txtpt.Text & " ', '" & txtphone.Text & "' ,' " & txtemail.Text & " ');"
Dim dbcommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbcommand.CommandText = queryString
dbcommand.Connection = dbconnection
dbconnection.Open()
Dim rowsAffected As Integer = 0
Try
rowsAffected = dbcommand.ExecuteNonQuery
MsgBox("Record Saved")
Catch
MsgBox("Record not saved")
Finally
dbconnection.Close()
Me.Close()
End Try
Last edited by a moderator: