日期:2014-05-18 浏览次数:20425 次
Dim connstring As String Dim As String Dim conn As New SqlConnection Dim i As Integer, j As Integer connstring = "ata source=localhost; connstring &= "duid=SQL2000用户名;pwd=SQL2000密码;database=连接的数据库 conn.ConnectionString = connstring conn.Open()
------解决方案--------------------
c#的一个例子
string myConnStr="Data Source=locolhost;"; myConnStr+="Initial Catalog=数据库;";//注意“数据库”是你想连接的数据库(一定是数据库,不能是表) myConnStr+="Integrated Security=true"; SqlConnection myConn = new SqlConnection(myConnStr); try { myConn.Open(); } catch (SqlException SqlEx) { this.Response.Write("错误:<br/>" + SqlEx.Message.ToString()); } finally { if (myConn.State == ConnectionState.Open) { myConn.Close(); } }