String strServerName = "服务器名或IP"; String strUserID = "数据库用户名"; String strPSW= "数据库密码"; DataTable DBNameTable = new DataTable(); OleDbConnection Connection = new OleDbConnection(String.Format("Provider=SQLOLEDB;Data Source={0};User ID={1};PWD={2}", strServerName, strUserID, strPSW)); Connection.Open(); OleDbDataAdapter oleAdpt = new OleDbDataAdapter("select * from sysdatabases", Connection); oleAdpt.Fill(DBNameTable); Connection.Open();