编译错误,排错
using System;using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("user id=test;password=aaa;database=pay;server=aaa-5ffb53b4342");
SqlCommand cmd = new SqlCommand("Pay_SitePoint_GetPoint",conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter para = new SqlParameter();
para.ParameterName = "@username";
para.SqlDbType = SqlDbType.VarChar;
para.Direction = ParameterDirection.Input;
para.Value = TextBox1.Text.Trim();
cmd.Parameters.Add(para);
para.ParameterName = "@FreePoint";
para.SqlDbType = SqlDbType.Decimal;
para.Direction = ParameterDirection.Output;
para.ParameterName = "@BuyPoint";
para.SqlDbType = SqlDbType.Decimal;
para.Direction = ParameterDirection.Output;
conn.Open();
SqlDataReader myDataReader = cmd.ExecuteReader();
while (myDataReader.Read())
{
Response.Write(myDataReader.GetDecimal(0)+","+myDataReader.GetDecimal(0));
}
myDataReader.Close();
conn.Close();
}
}
编译提示: 过程或函数 'Pay_SitePoint_GetPoint' 需要参数 '@UserName',但未提供该参数。
请帮忙找出错误.
功能就是调一个存储过程,输入一个参数.输出二个参数.
--------------------编程问答--------------------
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("user id=test;password=aaa;database=pay;server=aaa-5ffb53b4342");
SqlCommand cmd = new SqlCommand("Pay_SitePoint_GetPoint", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", TextBox1.Text.Trim());
cmd.Parameters.Add("@FreePoint", SqlDbType.Decimal).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@BuyPoint", SqlDbType.Decimal).Direction = ParameterDirection.Output;
conn.Open();
SqlDataReader myDataReader = cmd.ExecuteReader();
while (myDataReader.Read())
{
//下面有点问题,怎么下标都是0?
Response.Write(myDataReader.GetDecimal(0) + "," + myDataReader.GetDecimal(0));
}
myDataReader.Close();
conn.Close();
}
补充:.NET技术 , ASP.NET