<%@ Page Language="VB" AutoEventWireup="false" CodeFile="TestConnect.aspx.vb" Inherits="TestConnect" %>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<script runat="server">
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Sub Page_Load(sender As Object, e As EventArgs)
Dim strConnString As String
strConnString = "Server=KOMAGI-PC\SQLEXPRESS;Uid=Komagi-PC\Komagi;PASSWORD=;database=CP; Pooling=false;"
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
</script>
<html>
<head runat="server">
<title>Test</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label id="lblText" runat="server"></asp:Label>
</div>
</form>
</body>
</html>