OleDbConnection.GetOleDbSchemaTable fails with period in the database name

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

None of the schema filters such as OleDbSchemaGuid.Tables work when a
database has a period "." in its name, such as "Test 7.7". Is this
expected? It doesn't seem like this should fail since OleDb is a
generic mechanism and who knows what a DMBS will allow for a database
name.
 
Mike,

I don't know if this is expected or not, but I do now, that naming tables in
such mode leads to errors and problems.
I would really suggest you to use only a-z0-9 chars for metadata naming in
database.
 
How to duplicate

try
{
OleDbConnection cn = new OleDbConnection("Provider=SQLOLEDB.1;
Persist Security Info=False; User ID=sa;
Data Source=localhost");

cn.Open();
object[] filter = new Object[] {"test 7.7", null, null, "TABLE"};

DataTable metaData = cn.GetOleDbSchemaTable(
OleDbSchemaGuid.Tables, filter);

cn.Close();
}
catch(Exception ex)
{
int i = 9; // set break point here
}

This yields the error:

{"Unspecified error\r\nCould not find server 'test 7' in sysservers.
Execute sp_addlinkedserver to add the server to sysservers." }
System.Exception
 
Well, it's definitely a bug, I have proof now.

OleDbSchemaGuid.Procedures - works

all other schema's fail, it's easy to test

try
{
OleDbConnection cn = new OleDbConnection("Provider=SQLOLEDB.1;
Persist Security Info=False;User ID=sa;
Data Source=localhost");

cn.Open();
object[] filter = new Object[] {"test 7.7", null, null, "TABLE"};

DataTable metaData = cn.GetOleDbSchemaTable(
OleDbSchemaGuid.Tables, filter);

cn.Close();
}
catch(Exception ex)
{
int i = 9; // set break point here
}

If you change the code to OleDbSchemaGuid.Procedures and remove the
"Table" it works fine, no other schema's work
 
Did you test with square brackets?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Mike said:
Well, it's definitely a bug, I have proof now.

OleDbSchemaGuid.Procedures - works

all other schema's fail, it's easy to test

try
{
OleDbConnection cn = new OleDbConnection("Provider=SQLOLEDB.1;
Persist Security Info=False;User ID=sa;
Data Source=localhost");

cn.Open();
object[] filter = new Object[] {"test 7.7", null, null, "TABLE"};

DataTable metaData = cn.GetOleDbSchemaTable(
OleDbSchemaGuid.Tables, filter);

cn.Close();
}
catch(Exception ex)
{
int i = 9; // set break point here
}

If you change the code to OleDbSchemaGuid.Procedures and remove the
"Table" it works fine, no other schema's work
 
Back
Top