01.
<%@ Page Language=
"C#"
AutoEventWireup=
"true"
CodeFile=
"connext.aspx.cs"
Inherits=
"connext"
Debug=
"true"
%>
02.
<%--<%@ Page Language=
"C#"
Debug=
"true"
%> --%>
04.
<%@ Import Namespace=
"System.Data"
%>
05.
<%@ Import Namespace=
"System.Data.SqlClient"
%>
06.
07.
<script runat=
"server"
>
08.
SqlConnection objConn;
09.
SqlCommand objCmd;
10.
void
Page_Load(
object
sender,EventArgs e)
11.
{
12.
String strConnString;
13.
strConnString =
"localhost:81 ;User Id=root;Password=piyapong;Database=mydatabase;Pooling=false"
;
14.
objConn =
new
SqlConnection(strConnString);
15.
objConn.Open();
16.
if
(objConn.State == ConnectionState.Open)
17.
{
18.
this
.lblText.Text =
"SQL Server Connected"
;
19.
}
20.
else
21.
{
22.
this
.lblText.Text =
"SQL Server Connect Failed"
;
23.
}
24.
}
25.
void
Page_UnLoad()
26.
{
27.
objConn.Close();
28.
objConn =
null
;
29.
}
30.
</script>
31.
32.
34.
<head runat=
"server"
>
35.
<title>Untitled Page</title>
36.
</head>
37.
<body>
38.
<form id=
"form1"
runat=
"server"
>
39.
<%-- <div>
40.
41.
42.
</div>--%>
43.
<asp:Label id=
"lblText"
runat=
"server"
></asp:Label>
44.
</form>
45.
</body>
46.
</html>