Inserting to Access Database

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi!

Need help. I want to insert values from textbox-based input and upon
clicking the Create button, these command lines will run. It didn't work! It
points to the "test.Insert()" line that indicates that "Keyword not
supported: 'provider'". See the code behind below:

Protected Sub btnCreate_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnCreate.Click
Dim test As SqlDataSource = New SqlDataSource()
test.ConnectionString =
ConfigurationManager.ConnectionStrings("dbaccountsCS").ToString
test.InsertCommand = "INSERT INTO [tblaccounts] ([UserName],
[FName], [LName], [Email], [Department],[Password]) VALUES (@UserName,
@FName, @LName, @Email, @Dept, @Password)"

test.InsertParameters.Add("UserName", txtUserName.Text)
test.InsertParameters.Add("FName", txtFName.Text)
test.InsertParameters.Add("LName", txtLName.Text)
test.InsertParameters.Add("Email", txtEmail.Text)
test.InsertParameters.Add("Dept", ddlDept.Text)
test.InsertParameters.Add("Password", txtPass.Text)

test.Insert() <<<<<<<<------ This line has an error

Label7.Visible = True

End Sub


.


Quantcast