I've been scouring the Net trying to get my head around using VB.NET to save information entered through text boxes on my form into an Access database. Most of what I see so far shows me how to display records already entered into the database and update the table, but I can't see how to add an empty database to my application. Can someone assist me by pointing me to or walking me through a step by step guide for capturing data entered via text boxes into a new database?



I want to add data to a table in a data base. this code have error in insert into statement. please solve this to me. thank you. [ujnimz]


Dim con As OleDbConnection
Dim com As OleDbCommand
Dim NAME As String
Try
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\NIMANTHA\Documents\DONUJ.accdb")
com = New OleDbCommand("INSERT INTO STUDENTS (StudentID, StudentName, Grade,TeacherIncharge)VALUES (@STID,@NAME,@GRADE,@TEACHER))", con)

con.Open()
MsgBox("DATABASE IS OPEN NOW")
com.Parameters.AddWithValue("@STID", TextBox1.Text)
com.Parameters.AddWithValue("@NAME", TextBox2.Text)
com.Parameters.AddWithValue("@GRADE", TextBox3.Text)
com.Parameters.AddWithValue("@TEACHER", TextBox4.Text)
com.ExecuteNonQuery()
NAME = TextBox2.Text
MsgBox("Add " & NAME & "'s status")
con.Close()
Catch ex As Exception
MsgBox(ErrorToString)
End Try

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.