sqlgetauthorcount.aspx
来自「asp.net技术内幕的书配源码」· ASPX 代码 · 共 25 行
ASPX
25 行
<%@ Page Language="C#"%>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<script runat=server>
void Page_Load(Object sender , EventArgs e)
{
SqlConnection conPubs;
SqlCommand cmdAuthorCount;
SqlParameter parmReturnValue;
int intAuthorCount;
conPubs = new SqlConnection( @"Server=localhost;Integrated Security=SSPI;database=pubs" );
cmdAuthorCount = new SqlCommand( "GetAuthorCount", conPubs );
cmdAuthorCount.CommandType = CommandType.StoredProcedure;
parmReturnValue = cmdAuthorCount.Parameters.Add( "ReturnValue", SqlDbType.Int );
parmReturnValue.Direction = ParameterDirection.ReturnValue;
conPubs.Open();
cmdAuthorCount.ExecuteNonQuery();
intAuthorCount = Convert.ToInt32(cmdAuthorCount.Parameters[ "ReturnValue" ].Value);
conPubs.Close();
Response.Write( String.Format("There are {0} records in the Authors table", intAuthorCount));
}
</script>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?