C#代碼的形式提供:@output這是不是在SQL Server
protected void btnsearch_Click(object sender, EventArgs e)
{
SqlConnection con = Connection.DBconnection();
SqlCommand com = new SqlCommand("sp_studentresult", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@id", textstudentid.Text);
SqlDataAdapter adp = new SqlDataAdapter(com);
DataSet ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
txtid.Text = ds.Tables[0].Rows[0]["id"].ToString();
txttamil.Text = ds.Tables[0].Rows[0]["Tamil"].ToString();
txtenglish.Text = ds.Tables[0].Rows[0]["English"].ToString();
txtmaths.Text = ds.Tables[0].Rows[0]["Maths"].ToString();
txtscience.Text = ds.Tables[0].Rows[0]["Science"].ToString();
txtsocialscience.Text = ds.Tables[0].Rows[0]["SocialScience"].ToString();
}
SqlParameter retval = new SqlParameter("@output", SqlDbType.VarChar, 50);
retval.Direction = ParameterDirection.Output;
com.Parameters.Add(retval);
com.ExecuteNonQuery();
string Output = retval.Value.ToString();
}
存儲過程:
ALTER PROCEDURE sp_studentresult
(
@id int,
@output varchar(50) output,
@id_student varchar(50)
)
AS
begin
SELECT * from studentresult where [email protected]
End
IF EXISTS (SELECT * FROM student WHERE [email protected]_student)
BEGIN
SET @output='EXIST'
END
我是新來的.NET。當我輸入學號和搜索時,我得到
過程或函數sp_studentresult指定的參數太多。
我可以知道我在上述代碼中的錯誤嗎?
任何幫助將不勝感激。
謝謝,
顯示的存儲過程的代碼 –
請張貼存儲過程'這裏sp_studentresult'所以我們知道哪些參數此存儲過程需要。 順便說一句,你檢查存儲過程實際上是在數據庫中嗎? – user3454439
你可以請檢查我的sp?謝謝 – pcs