954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Understanding inserting data into an Access table using VB.NET

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?

bajanpoet
Junior Poster in Training
96 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 
waynespangler
Posting Pro in Training
461 posts since Dec 2002
Reputation Points: 84
Solved Threads: 58
 

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

UJNimz
Newbie Poster
3 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You