RE: ADODB.Connection.OpenSchema from C#.NET 2.0



Hi Photog,

It is because of the last argument for OpenSchema you have specified, that
the exception was thrown. The last argument is a schemaID which cannot be
null. It is the GUID for a provider-schema query not defined by the OLE DB
specification.

Since you're developing an app in C#, I strongly suggest you use ADO.NET
instead of ADO. It works better in a .NET app and doesn't involve COM
Interop. In ADO.NET, if you need to get the schema of certain table in an
MSAccess database, you can use

OleDbConnection cnn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\db1.mdb;Persist Security Info=False");
cnn.Open();
DataTable dt = cnn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new object[] { null, null, "Table1", "TABLE" });
cnn.Close();

In ADO.NET 2.0, you can also use the following instead of
GetOleDbSchemaTable. Either will be fine.

dt = cnn.GetSchema("Tables", new string[] { null, null,
"Table1", "TABLE" });

If anything is unclear, please feel free to let me know.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

.