在C#中,使用Odbc连接Access数据库时,通过以下代码测试连接时,出现如下错误, 应该怎么样修改 5
staticvoidMain(string[]args){OdbcConnectionoc=newOdbcConnection();oc.ConnectionString...
static void Main(string[] args)
{
OdbcConnection oc = new OdbcConnection();
oc.ConnectionString = @"Driver={Microsoft Access Driver(*.mdb,*.accdb)};
dbq=D:\My Documents\罗斯文 2007.accdb;
defaultdir=D:\My Documents;
driverid=25;
fil=MS Access;
filedsn=C:\Program Files\Common Files\ODBC\Data Sources\yang110408.dsn;
maxBuffersize=2048;
maxscanrows=8;
pagetimeout=5;
safetransactions=0;
threads=3;
uid=admin;
usercommitsync=Yes;
try
{
oc.Open();
Console.WriteLine(oc.Database);
Console.WriteLine("数据库联接成功!");
}
catch (OdbcException oe)
{
Console.WriteLine("数据库联接失败!");
Console.WriteLine(oe.Message);
}
}
错误信息:
采用Ole连接数据库时
代码:
static void Main(string[] args)
{
OleDbConnection oc = new OleDbConnection();
oc.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=D:\My Documents\罗斯文 2007.accdb";
try
{
oc.Open();
Console.WriteLine(oc.ToString());
Console.WriteLine("数据库连接成功!");
}
catch (OleDbException oe)
{
Console.WriteLine("数据库连接失败!!");
Console.WriteLine(oe.Message);
}
}
错误信息:
找不到可安装的ISAM
这是什么意思? 展开
{
OdbcConnection oc = new OdbcConnection();
oc.ConnectionString = @"Driver={Microsoft Access Driver(*.mdb,*.accdb)};
dbq=D:\My Documents\罗斯文 2007.accdb;
defaultdir=D:\My Documents;
driverid=25;
fil=MS Access;
filedsn=C:\Program Files\Common Files\ODBC\Data Sources\yang110408.dsn;
maxBuffersize=2048;
maxscanrows=8;
pagetimeout=5;
safetransactions=0;
threads=3;
uid=admin;
usercommitsync=Yes;
try
{
oc.Open();
Console.WriteLine(oc.Database);
Console.WriteLine("数据库联接成功!");
}
catch (OdbcException oe)
{
Console.WriteLine("数据库联接失败!");
Console.WriteLine(oe.Message);
}
}
错误信息:
采用Ole连接数据库时
代码:
static void Main(string[] args)
{
OleDbConnection oc = new OleDbConnection();
oc.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=D:\My Documents\罗斯文 2007.accdb";
try
{
oc.Open();
Console.WriteLine(oc.ToString());
Console.WriteLine("数据库连接成功!");
}
catch (OleDbException oe)
{
Console.WriteLine("数据库连接失败!!");
Console.WriteLine(oe.Message);
}
}
错误信息:
找不到可安装的ISAM
这是什么意思? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询