4 Replies - 299 Views - Last Post: 29 January 2013 - 12:17 AM Rate Topic: -----

#1 alobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 21-January 13

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
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()


Is This A Good Question/Topic? 0
  • +

Replies To: VB.Net Exception

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9388
  • View blog
  • Posts: 35,248
  • Joined: 12-June 08

Re: VB.Net Exception

Posted 28 January 2013 - 07:41 PM

Care to share what the exception text is?
Was This Post Helpful? 0
  • +
  • -

#3 alobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 21-January 13

Re: VB.Net Exception

Posted 28 January 2013 - 09:48 PM

View Postalobi, 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.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9388
  • View blog
  • Posts: 35,248
  • Joined: 12-June 08

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
Was This Post Helpful? 1
  • +
  • -

#5 alobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 21-January 13

Re: VB.Net Exception

Posted 29 January 2013 - 12:17 AM

View Postmodi123_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


Thank you very much for your time
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1