RE: ADODB.Connection.OpenSchema from C#.NET 2.0
- From: v-kevy@xxxxxxxxxxxxxxxxxxxx (Kevin Yu [MSFT])
- Date: Fri, 07 Jul 2006 04:19:19 GMT
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.)
.
- Follow-Ups:
- Re: ADODB.Connection.OpenSchema from C#.NET 2.0
- From: Photog
- Re: ADODB.Connection.OpenSchema from C#.NET 2.0
- References:
- ADODB.Connection.OpenSchema from C#.NET 2.0
- From: Photog
- ADODB.Connection.OpenSchema from C#.NET 2.0
- Prev by Date: why can I not get autonumber value to add to another table in data
- Next by Date: Re: why can I not get autonumber value to add to another table in data
- Previous by thread: ADODB.Connection.OpenSchema from C#.NET 2.0
- Next by thread: Re: ADODB.Connection.OpenSchema from C#.NET 2.0
- Index(es):