Code:
Dear members,
I need help figuring out why I am having an exception on this line of code, will appreciate all help thanks .
Please free to make any suggestion as you see fit I am sure that there will be more issues with this code because I am new to VB.Net. I do expect more issue. Any suggestions will be greatly appreciated.
Here are my Codes
Dim strConn As String 'This declares or creats the connection string
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Amaechi\Documents\Databases\StudentRec.accdb"
Dim myconn As New SqlConnection(strConn) <<<<<The exception is on this line
Dim InSertLast As String = "insert into StudentTbl(FirstName,LastName)Values (@FirstName, @LastName)"
'declare sql Command
Dim insert As New SqlCommand(InSertLast, myconn)
'use the WITH Loop fuction to loop through the data in the text boxes
With insert.Parameters
.Add(New SqlParameter("@FirstName", TxtFirstName.Text.Trim))
.Add(New SqlParameter("@FirstName", TxtLastName.Text.Trim))
End With
' The Connection to the database
myconn.Open()
insert.ExecuteNonQuery() 'excute Query
myconn.Close()
End Sub