aspdotnet connection Sql server

来源:互联网 发布:经济学的书 知乎 编辑:程序博客网 时间:2024/04/28 17:28

<%@ Page Language="vb" %>

<%@ Import Namespace = "System.Data" %>

<%@ Import Namespace = "System.Data.SQL" %>

<html>

  <head>

  <script runat=server>

       Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)

              'On Error Resume Next

              Dim cn           As SQLConnection

              cn = New SQLConnection("server=localhost;uid=sa;pwd=;database=pubs;")

              cn.Open()

              If cn.State = 1 Then

                     lblReturnCode.Text = "The Connection State is: " & cn.State & " - Connection Succeeded"

              Else

                     lblReturnCode.Text = "The Connection State is: " & cn.State & " - Connection Failed"

              End If

        End Sub

  </script>

  </head>

  <body>

       <asp:Label id="lblReturnCode" Runat=server />

  </body>

</html>

原创粉丝点击