Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have an windows 10 64 bit system.in that system microsoft access 2007 is installed. my code is
Try
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim myCommand As New System.Data.OleDb.OleDbCommand
Dim sql As String

MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.12.0;Data Source='" + HistPath + "\Message_History.xls';Extended Properties=Excel 8.0;")

MyConnection.Open()
myCommand.Connection = MyConnection
If (typ = "S") Then
sql = "Insert into [Success$] values('" & destination & "','" & messg & "','" & errormsg & "','" & System.DateTime.Now & "')"
Else
sql = "Insert into [Error$] values('" & destination & "','" & messg & "','" & errormsg & "','" & System.DateTime.Now & "')"
End If

myCommand.CommandText = sql
myCommand.ExecuteNonQuery()
MyConnection.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try

What I have tried:

plz solve my problem.i am facing issue with this.already i have changed the built from any cpu to x86
Posted
Updated 27-Sep-18 5:00am
v2
Comments
ZurdoDev 27-Sep-18 10:16am    
Did you google the error?

It's saying - pretty clearly - that the JET DB engine is not installed on the computer (and you probably shouldn't be using JET anyway, it was replaced by ACE many years ago, and will never be available in a 64 bit version).

But that's not the worst of your mistakes: Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead.

When you concatenate strings, you cause problems because SQL receives commands like:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood'
The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable;--'
Which SQL sees as three separate commands:
SQL
SELECT * FROM MyTable WHERE StreetAddress = 'x';
A perfectly valid SELECT
SQL
DROP TABLE MyTable;
A perfectly valid "delete the table" command
SQL
--'
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.

So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?
 
Share this answer
 
Comments
Member 13999803 28-Sep-18 3:39am    
By changing jet to ace there isan error like System.Data.Oledb.OleDbexception:themicrosoft office access database engine could not find the object 'Success$'
Member 13999803 28-Sep-18 3:41am    
Imports System
Imports System.Data
Imports System.Net
Imports System.IO


Public Class SendMsg
Public Shared connectionURL As String = String.Empty
Public Shared username As String = String.Empty
Public Shared password As String = String.Empty
Public Shared type As String = String.Empty
Public Shared dlr As String = String.Empty
Public Shared source As String = String.Empty
Public Shared CompleteURL As String = String.Empty
Public Shared HistPath As String = String.Empty
Public Shared Statuscode As HttpWebResponse
''' <summary>
''' Initialize connectionURL
''' 0
''' <param name="URI">
''' <remarks>
Public Shared Sub SetURL(ByVal URI As String, ByVal usernam As String, ByVal pswd As String, ByVal tp As String, ByVal dl As String, ByVal src As String, ByVal histp As String)
connectionURL = URI
username = usernam
password = pswd
type = tp
dlr = dl
source = src
HistPath = histp
End Sub
''' <summary>
''' Sending Message
'''
''' <param name="Dest">
''' <param name="msg">
''' <remarks>
Public Shared Sub StartMsgSend(ByVal Dest As String, ByVal msg As String)
'Dim SourceStream As System.IO.Stream
'Dim myRequest As System.Net.WebRequest = WebRequest.Create(connectionURL)
'myRequest.Credentials = CredentialCache.DefaultCredentials
'Dim webResponse As WebResponse = myRequest.GetResponse
'SourceStream = webResponse.GetResponseStream()
'Dim reader As StreamReader = New StreamReader(webResponse.GetResponseStream())
CompleteURL = connectionURL + "?username=" + username + "&password=" + password + "&type=" + type + "&dlr=" + dlr + "&destination=" & Dest & "&source=" + source + "&message=" & msg & ""

''CompleteURL = connectionURL + "?loginID=" + username + "&password=" + password + "&mobile=" & Dest & "&text=" & msg & "&senderid=" + source + "&route_id=" + type + "&Unicode=" + dlr + ""


Try
' Creates an HttpWebRequest with the specified URL.
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(CompleteURL), HttpWebRequest)
' Sends the request and waits for a response.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Statuscode = myHttpWebResponse
If myHttpWebResponse.StatusCode = HttpStatusCode.OK Then
writexcel(Dest, msg, "S", myHttpWebResponse.StatusDescription.ToString)
Else
writexcel(Dest, msg, "E", myHttpWebResponse.StatusDescription.ToString)
End If
' Release the resources of the response.
myHttpWebResponse.Close()

Catch e As WebException
writexcel(Dest, msg, "E", e.Message)
Catch e As Exception
writexcel(Dest, msg, "E", e.Message)
End Try

End Sub


Public Shared Sub writexcel(ByVal destination As String, ByVal messg As String, ByVal typ As String, ByVal errormsg As String)
Try
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim myCommand As New System.Data.OleDb.OleDbCommand
Dim sql As String

MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.4.0;Data Source='" + HistPath + "\Message_History.xls';Extended Properties=Excel 8.0;")

MyConnection.Open()
myCommand.Connection = MyConnection
If (typ = "S") Then
sql = "Insert into [Success$] values('" & destination & "','" & messg & "','" & errormsg & "','" & System.DateTime.Now & "')"
Else
sql = "Insert
The provider name you specified, "Microsoft.Jet.OLEDB.12.0", never existed. I don't know where you got that from, but it's not correct at all.

The old JET provider was called "Microsoft.Jet.OLEDB.4.0". That's for Access databases in the older Access 2003 and below format.

The correct provider name for Access 2007 and above is "Microsoft.ACE.OLEDB.12.0".
 
Share this answer
 
Comments
Member 13999803 28-Sep-18 3:36am    
By changing jet to ace there isan error like System.Data.Oledb.OleDbexception:themicrosoft office access database engine could not find the object 'Success$'
Dave Kreskowiak 28-Sep-18 8:18am    
You have the EXACT same problem. I gave you the TWO POSSIBLE provider names to use and you, again, went with option 3, an invalid name.
Member 13999803 28-Sep-18 3:41am    
Imports System
Imports System.Data
Imports System.Net
Imports System.IO


Public Class SendMsg
Public Shared connectionURL As String = String.Empty
Public Shared username As String = String.Empty
Public Shared password As String = String.Empty
Public Shared type As String = String.Empty
Public Shared dlr As String = String.Empty
Public Shared source As String = String.Empty
Public Shared CompleteURL As String = String.Empty
Public Shared HistPath As String = String.Empty
Public Shared Statuscode As HttpWebResponse
''' <summary>
''' Initialize connectionURL
''' 0
''' <param name="URI">
''' <remarks>
Public Shared Sub SetURL(ByVal URI As String, ByVal usernam As String, ByVal pswd As String, ByVal tp As String, ByVal dl As String, ByVal src As String, ByVal histp As String)
connectionURL = URI
username = usernam
password = pswd
type = tp
dlr = dl
source = src
HistPath = histp
End Sub
''' <summary>
''' Sending Message
'''
''' <param name="Dest">
''' <param name="msg">
''' <remarks>
Public Shared Sub StartMsgSend(ByVal Dest As String, ByVal msg As String)
'Dim SourceStream As System.IO.Stream
'Dim myRequest As System.Net.WebRequest = WebRequest.Create(connectionURL)
'myRequest.Credentials = CredentialCache.DefaultCredentials
'Dim webResponse As WebResponse = myRequest.GetResponse
'SourceStream = webResponse.GetResponseStream()
'Dim reader As StreamReader = New StreamReader(webResponse.GetResponseStream())
CompleteURL = connectionURL + "?username=" + username + "&password=" + password + "&type=" + type + "&dlr=" + dlr + "&destination=" & Dest & "&source=" + source + "&message=" & msg & ""

''CompleteURL = connectionURL + "?loginID=" + username + "&password=" + password + "&mobile=" & Dest & "&text=" & msg & "&senderid=" + source + "&route_id=" + type + "&Unicode=" + dlr + ""


Try
' Creates an HttpWebRequest with the specified URL.
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(CompleteURL), HttpWebRequest)
' Sends the request and waits for a response.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Statuscode = myHttpWebResponse
If myHttpWebResponse.StatusCode = HttpStatusCode.OK Then
writexcel(Dest, msg, "S", myHttpWebResponse.StatusDescription.ToString)
Else
writexcel(Dest, msg, "E", myHttpWebResponse.StatusDescription.ToString)
End If
' Release the resources of the response.
myHttpWebResponse.Close()

Catch e As WebException
writexcel(Dest, msg, "E", e.Message)
Catch e As Exception
writexcel(Dest, msg, "E", e.Message)
End Try

End Sub


Public Shared Sub writexcel(ByVal destination As String, ByVal messg As String, ByVal typ As String, ByVal errormsg As String)
Try
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim myCommand As New System.Data.OleDb.OleDbCommand
Dim sql As String

MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.4.0;Data Source='" + HistPath + "\Message_History.xls';Extended Properties=Excel 8.0;")

MyConnection.Open()
myCommand.Connection = MyConnection
If (typ = "S") Then
sql = "Insert into [Success$] values('" & destination & "','" & messg & "','" & errormsg & "','" & System.DateTime.Now & "')"
Else
sql = "Insert

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900