Could not find installable ISAM with excel 16.0 - vb.net

I'm trying to load an excel file to datagridview however I keep getting the error "could not find installable ISAM." I tried what other posts said about changing where I put my single quotes but I still keep getting that error. This is what I have right now.
conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.16.0;Data Source='C:\Users\test.xlsx';Extended Properties='Excel 16.0;';")
Thanks for the help in advance!

You need install Microsoft Access Runtime
https://support.microsoft.com/en-us/office/download-and-install-microsoft-365-access-runtime-185c5a32-8ba9-491e-ac76-91cbe3ea09c9
And make sure your project is match de architecture of your ACE Runtime.
I'll just recommend to use OLEDB.12.0 as this and remove excess of '
OleDbConnection conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\test.xlsx;Extended Properties='Excel 8.0;';")

Related

Getting an E_OUTOFMEMORY when accessing an Access database with OLEDB

We have this VB.net code that connects to an MS Access Database and tries to insert a new entry:
Dim conn As New OleDbConnection
conn.ConnectionString = "Provider="Microsoft.ACE.OLEDB.16.0; Data Source=" & DATABASE_PATH & ";Jet OLEDB:Database Password=pass;"
conn.Open()
Dim SqlString As String = "INSERT INTO tblNotes" &
" ([NotesNumber" &
"], [NotesTitle" &
"], [HasAdditionalLogic" &
"], [TypeId]) Values (?,?,?,?)"
Dim cmd As New OleDbCommand(SqlString, conn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("NotesNumber", 1234)
cmd.Parameters.AddWithValue("NotesTitle", "the title")
cmd.Parameters.AddWithValue("HasAdditionalLogic", False)
cmd.Parameters.AddWithValue("TypeId", 14)
cmd.ExecuteNonQuery()
conn.close()
Nothing too fancy, right?
This code worked fine with Access 2016 installed.
Now with the recent upgrade to Office 365 the line
cmd.ExecuteNonQuery()
causes this error:
'Microsoft.ACE.OLEDB.16.0' failed with no error message available, result code: E_OUTOFMEMORY(0x8007000E)
Googling for that error message lead to several ideas like using Integer instead of Long Integer in the database, but that did not help either.
And personally, I doubt that the root cause is a lack of memory because the machine has 32GB RAM installed and is set to 32GB of Virtual Memory. The process itself never uses more than 100MB, Windows Process Explorer tells us that the whole RAM uses about 5GB total. So I just cannot believe we are actually running out of memory here.
Any idea?
Update:
Okay, we seem to have found the underlying issue here.
You see this line:
cmd.Parameters.AddWithValue("TypeId", 14)
In the Access database, the field "TypeId" has been defined as a Primary Key of Data Type "AutoNumber" and Field Size "Long Integer".
Now, if we write the code like this:
cmd.Parameters.AddWithValue("TypeId", 14I)
it runs without an error, but as soon as we change it to:
cmd.Parameters.AddWithValue("TypeId", 14L)
we get the crash.
Let me state again that the code with a Long works fine with Access 2016, it crashes with the Access from Office 365.
I may be mistaken, but this seems like a bug in Access.
Of course we can now change all the app code from Long to Integer (or UInteger), but this seems like treating the symptoms instead of the root cause.
Can somebody confirm this? Or tell me why exactly this happens? Using a Long seems to be correct to me, using an Integer instead seems pretty wrong to me.
To anybody who might face the same problem: we "fixed" the issue by installing "Microsoft Access Database Engine 2010 Redistributable"
https://www.microsoft.com/en-US/download/details.aspx?id=13255
and then using
Microsoft.ACE.OLEDB.12.0
instead of
Microsoft.ACE.OLEDB.16.0
That did the trick.
The hint with .add instead of .addWithValue did not make any difference.

VB.net - Get error "Attempted to read or write protected memory..." since provider changed

That's my first post here, so please indicate me if there are some missing useful informations' to help to solve my problem.
Here is it:
I have a VB.net application using Access database (.mdb), which worked properly for years.
Because I'm using now Access Database Engine 2016 in 64-bits, I have changed my DB connection provider from Microsoft.Jet.OLEDB.4.0 (only available in 32-bits) to Microsoft.ACE.OLEDB.12.0. I've also unchecked in my app's properties "32-bits prefered" (translation from my French version of Visual Studio).
Since I did these changes (and only them), I often get the following error:
System.AccessViolationException: 'Attempted to read or write
protected memory. This is often an indication that other memory is
corrupt.
It appears (randomly) in different parts of the software, always at the line myConnection.Open()
Dim myConnection As OleDbConnection = New OleDbConnection(S7ConnString)
Try
myConnection.Open()
...
First new connection string with which I began to get this problem is:
Public S7ConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & DBPath & ";Jet OLEDB:Database Password=***;"
(where DBPath is a string for the Access .mdb file path)
After some searches, I've read that adding OLE DB Services=-1 could solve it. It improved speed of DB processes really much, but did not solved the problem.
Would you have any idea to solve this?
Thank you & Kind regards.
I have uninstalled Access Database Engine 2016 and installed 2010 64-bits version, and it seems to work correctly now.
Thank you for your suggestions, #Jimi, that helped me to solve this. I did not imagine "Microsoft.ACE.OLEDB.12.0" provider was not compatible with MS Access Database Engine 2016!

How to process excel file in vb.net without office installed

I am fairly new to VB.net and never used it for processing Office files.
Right now I have to look at Excel file and send some emails based on the data in the cells. I do not need to write anything to these files.
So far I have read quite a bit about PIAs and so far it looks that I have to design my application for particular Office version?
Is there a way to write the application which could handle files created by different versions of MS Excel?
I would like to be able to process these files without Office being installed on the computer at all, is there any way to do it?
You could use Open XML SDK 2.0 for Microsoft Office link
Don't need to install Office for getting data from excel file.
But for getting data from EXCEL fileyou have to install OLEDB driver in your local machine as well as server if you are hosted your application on server.
You can download OLEDB driver from MICROSOFT.
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + YourEXCELFilePath + ";Extended Properties=Excel 12.0;")
con.Open()
atatable = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
sheetname = datatable.Rows(0)("table_name").ToString
excelcomm = New OleDbCommand("select * from [" + sheetname + "]", con)
adexcel = New OleDbDataAdapter(excelcomm)
adexcel.Fill(Dataset)
After this code you will get excel sheet data in dataset.
Might this code can help you to get data from excel file.
(NOTE:this code is in vb.net)
you can use
npoi
epplus
which do not require excel

SSCE - Multiple-Step OLE DB operation generated errors

I'm using a SQL Server Compact database (3.5). I have run through every article on this site (and others) I could find about this issue, but can't seem to find the problem. I am using Visual Studio 2012, VB.Net.
My provider string is:
Dim sqlConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.SQLServer.CE.OLEDB.3.5;Data Source=" & My.Application.Info.DirectoryPath & "\pw.sdf" & ";Password=XXXyyy1234;Persist Security Info=True;")
My code where it all breaks down is:
'Create SQL Query
Dim SQLString As String = "SELECT * FROM EmailGroups"
'Create Dataset, Open Connection
Dim dsPWC As New DataSet()
Dim OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(SQLString, sqlConn)
sqlConn.Open()
And, of course, it breaks down on .Open().
I picked selecting from that datatable because it is a simple one.
EmailGroup_UID [int][PK]
EmailGroup_Name [nvarchar][length=50]
I'm sure I've been simply staring at this too long and can't see the forest for the trees anymore, so I'm hoping someone can slap me straight :)
Thanks in advance.
EDIT: This code all works when tying to the original MS Access 2007 database (accdb). Different provider, of course. And - I didn't import the tables, I re-created manually.
2nd EDIT: Immediate Window says 'A first chance exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll'
You should use SqlCeConnection instead of OldDbConnection.
if you must use OleDbConnection, use "ssce:database password" like so:
"Provider=Microsoft.SQLServer.CE.OLEDB.3.5;Data Source=" & My.Application.Info.DirectoryPath & "\pw.sdf" & ";SSCE:Database Password=XXXyyy1234;Persist Security Info=True;"

System.Transactions.Diagnostics.DiagnosticTrace threw an exception

Can someone please look into this and help me out..................
I recently developed a VB.NET utility for extracting data from a DB2 table and populating an HTML report format. I am using ISeries ODBC provider for connection. The utility seems to be working fine for most users.
For some users, apparently the ones without admin privileges on their systems, this fails to work. The users are getting the below error:
System.Transactions.Diagnostics.DiagnosticTrace threw an exception
The error occurs on the connection.Open line of the DB connection section.
Dim cn = New OdbcConnection("DSN=dsnname;UID=user;PWD=pswd")
Dim cmd As New OdbcCommand(qry, cn)
cn.Open() ' here
Is there any way to resolve this without granting admin privilege to the users?
There was something wrong with my App.Config file.
I deleted it and added a new one from a new project and it fixed it for me.