I am trying to create a web form which would add records to a Microsoft Access database (accbd format).
This will include several text boxes and drop down lists. But for the beginning I've created only two text boxes - ID and Namef. Also, I' ve put a gridview item on the page so I can see changes in data as they occur.
After launching the page in a browser, filling the ID and Namef fields and pressing "submit" button I recieve and error message:
My knowledge of asp.net and web programming in general is quite limited, so I based my form on code shown in that video:
My vb code is:
Partial Class _Default
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim myConn As OleDbConnection
Dim cmd As OleDbCommand
Dim sqlString, ID, Namef As String
ID = TxtID.Text
Namef = txtNamef.Text
myConn = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=|DataDirectory|Database1.accdb;")
sqlString = "INSERT INTO Table1 (ID, Namef) VALUES ('" + ID + "', '" + Namef + "')"
cmd = New OleDbCommand(sqlString, myConn)
I also attach an archive containing my project. The database is stored in App_Data folder.
Thanks in advance!