📄 sqlexecutescalar.aspx
字号:
<%@ Page Language="C#"%>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat=server>
void Page_Load(Object sender , EventArgs e)
{
SqlConnection conPubs;
SqlCommand cmdSelectCount;
conPubs = new SqlConnection( @"Server=localhost;Integrated Security=SSPI;database=Pubs" );
conPubs.Open();
cmdSelectCount = new SqlCommand( "Select Count(*) From Authors", conPubs );
lblResults.Text = cmdSelectCount.ExecuteScalar().ToString();
conPubs.Close();
}
</Script>
<html>
<head><title>SqlExecuteScalar.aspx</title></head>
<body>
There are
<asp:Label
ID="lblResults"
Runat="Server" />
in the Authors database table.
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -