Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

VB.Net Exception

$
0
0
In getting an exception at 'myConn.Open() could anybody help me. Thanks for your time
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 OleDbConnection(strConn)
Dim InSertLast As String = "insert into StudentTbl(FirstName,LastName)Values (@FirstName, @LastName)"
'declare sql Command
Dim insert As New OleDbCommand(InSertLast, myconn)
'use the WITH Loop fuction to loop through the data in the text boxes
With insert.Parameters
    .Add(New OleDbParameter("@FirstName", TxtFirstName.Text.Trim))
    .Add(New OleDbParameter("@FirstName", TxtLastName.Text.Trim))
End With
' The Connection to the database
[u]myconn.Open()[/u]
Dim Affected As Integer = 0

Affected = insert.ExecuteNonQuery() 'excute Query
If Affected = 1 Then
    MessageBox.Show("Success")
Else
    MessageBox.Show("Failed")
End If

myconn.Close()

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>