[Mono-list] Problem accessing an Access database in C#
monodanmorg at yahoo.com
Sat Oct 15 14:31:58 EDT 2011
OLE-DB in namespace System.Data.OleDb is not supported on Mono. OLE-DB is not maintained. There are some old bindings internally to libgda; however, libgda breaks backwards compatibility all the time. Going this route is a big waste of time.
Because OleDb is part of the System.Data.dll assembly, we cannot simply remove it.
You could try creating your own C# bindings to mdbtools. You can do an internet search to see if someone has. But, I think this is a waste of time too.
Maybe there is an ODBC driver to mdbtools. If there is, you can use the ODBC functionality in Mono's System.Data.Odbc.
My suggestion would be to convert your Access database to a DBMS that Mono has support for, such as, a SQLite database.You can use Mono's Mono.Data.Sqlite provider or use the provider from the sqlite.org
There is even a fully managed C# implementation of SQLite called C#-Sqlite:
From: Paul Johnson <paul at all-the-johnsons.co.uk>
To: mono-list at lists.ximian.com
Sent: Saturday, October 15, 2011 12:47 PM
Subject: [Mono-list] Problem accessing an Access database in C#
I seem to have hit a problem when try to drag data from an Access file. I know I can do it as I've populated some combo boxes using pretty much the same code, however, the code below is returning nothing and I cannot see why!
Any help would be appreciated
private void searchInformation(List<string> detail, List<bool> opts)
int id = 0;
string commandString = "Select TutorID from TutorNames WHERE Name = '" + detail + "'";
OleDbCommand objCommand = new OleDbCommand(commandString, conn);
OleDbDataReader reader = objCommand.ExecuteReader();
while (reader.Read() == true)
id = (int)reader["TutorID"];
catch (Exception e)
if (id == 0)
MessageBox.Show(detail + " doesn't exist on the database", "Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(detail + " exists, ID = " + id.ToString(), "Database");
details contains the name to be searched for (directly from a TextBox). TutorID exists in the TutorNames table and for test purposes, I'm using data that I know exists.
The only thing I can think of is that there are some escape characters at the end of the text (either being passed in or in the database) - everything else seems valid.
I have tried
"Select * from TutorNames where Name = '" + details + "'" to see if I can see TutorID, but nothing is being returned.
Additionally, I've tried another tack using a DataSet and DataTable in a similar way to the ways shown on MSDN, but still nothing.
Any clues would be appreciated!
Mono-list maillist - Mono-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-list