Reproducable OleDb bug

M

Mike

Calling OleDbConnection.GetOleDbSchemaTable on a SQL Database that has
a period in it's name fails: How to duplicate, create a database
called "test 7.7" and try this code.

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
 
P

Patrice

Try "[test 7.7]" instead.

The period is used by sql server to separate a full table name into
components.

Patrice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top