C#连接SQL2000 问题
string connStr,selectCmd;
connStr = "Server=localhost;database=dbTest;uid=sa;pwd=8630104; ";
selectCmd = "select * from tbTest ";
SqlConnection conn;
SqlCommand cmd;
SqlDataReader reader;
conn = new SqlConnection(connStr);
conn.Open();
cmd = new SqlCommand(selectCmd,conn);
SQL2000的密码已经设为8630104,默认的数据库也是dbTest,但为什么连接不上呢? cmd = new SqlCommand(selectCmd,conn);报错!
请高手指点,谢谢!
------解决方案--------------------cmd = new SqlCommand(selectCmd,conn);报错!
============================================
报什么错?
Server=127.0.0.1 试一下
------解决方案-------------------- OleDbConnection myConnection = new OleDbConnection(ConnStringDB);
OleDbCommand myCommand = new OleDbCommand(ListString,myConnection);
myConnection.Open();
OleDbDataReader myReader;
myReader = myCommand.ExecuteReader();
// Always call Read before accessing data.
while (myReader.Read())
{
}
myCommand.Dispose();
// always call Close when done reading.
myReader.Close();
// Close the connection when done with it.
myConnection.Close();
------解决方案--------------------Server=localhost
用
server=服务器名称或IP试试
------解决方案--------------------connStr = "Server=localhost;database=dbTest;uid=sa;pwd=8630104; ";
改为
connStr = "Server=(local);database=dbTest;uid=sa;pwd=8630104; ";
------解决方案--------------------server=(local)
------解决方案--------------------连接串 Server =(local)