Public Sub connectAD()
strConn = "Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ecomware;Data Source="
Conn = New System.Data.SqlClient.sqlConnection(strConn)
If Conn.State = ConnectionState.Open Then
Conn.Close()
End If
Conn.ConnectionString = strConn
Conn.Open()
End Sub
Dim connStr As String = "Data Source=nameServer;Initial Catalog=mydatabase;User Id=sa;Password=;"
Dim objCon As SqlConnection
objCon = New SqlConnection(connStr)
objCon.Open()
If objCon.State = ConnectionState.Open Then
MsgBox("Connect Success")
Else
MsgBox("Connect Failed")
End If
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Sub Page_Load(sender As Object, e As EventArgs)
Dim strConnString As String
strConnString = "Server=localhost;Uid=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
objConn = New SqlConnection(strConnString)
objConn.Open()
If objConn.State = ConnectionState.Open Then
Me.lblText.Text = "SQL Server Connected"
Else
Me.lblText.Text = "SQL Server Connect Failed"
End IF
End Sub
Sub Page_UnLoad()
objConn.Close()
objConn = Nothing
End Sub