当前位置: 代码迷 >> ASP.NET >> asp.net怎的连接SQL server2000
  详细解决方案

asp.net怎的连接SQL server2000

热度:8556   发布时间:2013-02-25 00:00:00.0
asp.net怎样连接SQL server2000?
asp.net怎样连接SQL server2000?我看到书上的一个例子是这样写的:
  Dim connstring As String
  Dim As String
  Dim conn As New SqlConnection
  Dim i As Integer, j As Integer
  connstring = "data source=local;
  connstring &= "Integrated security=sspi;"Initial catalog=test"(test是我在sql2000中建立的一个表)
  conn.ConnectionString = connstring
  conn.Open()
但是总是连接不上,高手帮帮忙!

------解决方案--------------------------------------------------------

VB.NET code
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#的一个例子
C# code
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();      }}
  相关解决方案