how to insert values in access database in vb.net
I am making database project in vb. net. I have one table which has 9 columns. I have used access database as a server side. My problem is that, I can not insert new rows with values in a table. some body please, solve this problem and help me. Thanks.
CrishPosted Nov 30, 2010, 5:21 AM
If you used access database as a server side than i will give you some code just go for it and solve your issue to insert values in access database in vb.net
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickFirstName = txtFName.TextLastName = txtLName.TextDates = DisplayDate.TextTime = DisplayTime.TextUser = DisplayUsername.TextPC = DisplayPCName.TextValid = FalseIf FirstName = Nothing ThenMsgBox("Please enter First Name")Valid = FalseElseValid = TrueEnd IfIf LastName = Nothing ThenMsgBox("Please enter Last Name")Valid = FalseElseValid = TrueEnd IfIf Valid = True ThenDim Cmd As OleDbCommandDim SQL As StringDim objCmd As New OleDbCommandDim Con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\SignIn.mdb")SQL ="INSERT INTO UserInfo (*) VALUES ('"& FirstName &"', '"& LastName &"', '"& Dates &"', '"& Time &"', '"& User &"', '"& PC &"')"Cmd = New OleDbCommand(SQL, Con)Con.Open()objCmd = New OleDbCommand(SQL, Con)objCmd.ExecuteNonQuery()Con.Close()End IfEnd SubGomathi PalaniswamyPosted Oct 5, 2010, 4:29 AM
In this i have attached project for insert a value in access database.refer if