Basically I am trying get the table names for a particular DSN using C#.NET
string strDSN = lstDSN.SelectedItem.Value.ToString(); //strDSN = say
"foodmart 2000" which is my DSN on the machine, properly configured and
worrking
OleDbConnection Conn = new OleDbConnection(strDSN);
Conn.Open();
System.Data.DataTable schemaTable =
Conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[] {null, null,
null, "TABLE"});
lstTables.DataSource =schemaTable;
Conn.Close();
I get error which says "Format of the initialization string does not conform
to specification starting at index 0. "
the equivalent ADO code is as below
onst adSchemaTables = 20
' -- create objects
Dim objConn As ADODB.Connection
Dim objRs As ADODB.Recordset
Set objConn = New ADODB.Connection
objConn.Open "foodmart 2000"
' -- Get list of tables - ALL tables
Set objRs = objConn.OpenSchema(adSchemaTables)
' -- Walk the recordset
Do While Not objRs.EOF
If objRs("TABLE_TYPE") = "TABLE" Then
List1.AddItem (objRs("TABLE_NAME"))
End If
objRs.MoveNext
Loop
' -- Close all objects
objRs.Close
Set objRs = Nothing
objConn.Close
Set objConn = Nothing
thanks
Mark Rae said:
string strDSN = lstDSN.SelectedItem.Value.ToString();
OleDbConnection Conn = new OleDbConnection(strDSN);
Conn.Open();
Why the above code fails at line second. I want to open the conection
using OleDBConnection and want to pass the DSN there
You've really got to offer a bit more information if you expect people to
help you... E.g.
1) What is the value of strDSN?
2) How do you know that the second line fails? What error message are you
getting.