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()
VB.Net Exception
Page 1 of 14 Replies - 123 Views - Last Post: 29 January 2013 - 12:17 AM
#1
VB.Net Exception
Posted 28 January 2013 - 07:32 PM
In getting an exception at 'myConn.Open() could anybody help me. Thanks for your time
Replies To: VB.Net Exception
#2
Re: VB.Net Exception
Posted 28 January 2013 - 07:41 PM
Care to share what the exception text is?
#3
Re: VB.Net Exception
Posted 28 January 2013 - 09:48 PM
alobi, on 28 January 2013 - 07:32 PM, said:
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()
The exception: InvalidOperationException was Unhandled
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
#4
Re: VB.Net Exception
Posted 28 January 2013 - 11:38 PM
That means you need to install 'Microsoft.ACE.OLEDB.12.0' on the machine you are trying to run this.
https://www.microsof...s.aspx?id=13255
https://www.microsof...s.aspx?id=13255
#5
Re: VB.Net Exception
Posted 29 January 2013 - 12:17 AM
modi123_1, on 28 January 2013 - 11:38 PM, said:
That means you need to install 'Microsoft.ACE.OLEDB.12.0' on the machine you are trying to run this.
https://www.microsof...s.aspx?id=13255
https://www.microsof...s.aspx?id=13255
Thank you very much for your time
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|