<%@Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.SqlClient"%>
<script language="C#" runat="server">
protected void Page_Load(object sender,EventArgs e)
{
SqlConnection Conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnString"]);
try
{
Conn.Open();
SqlCommand Cmd=Conn.CreateCommand();
= CommandType.StoredProcedure;
= "get_user_name";
Cmd.Parameters.Add("@user_id", SqlDbType.Int);
Cmd.Parameters["@user_id"].Value = Session["userid"];
string strDeposit=Cmd.ExecuteScalar().ToString();
Response.Write("&res=1&Deposit=" + strDeposit);
}
catch (Exception ep)
{
Response.Write("&res=-1&ErrMsg=" + ep.Message);
}
finally
{
Conn.Close();
}
}
</script>
很典型的一个实例