Stored Procedure Update statement not working
back again with another Store Procedure problem, i want to make a 1 click
submit then update with ASP.Net, but seems not working for me..
heres the code in my class
public void assignofclass(string course, string id)
{
myCon.Open();
SqlCommand saveCmd = new SqlCommand("assignclass", myCon);
saveCmd.CommandType = CommandType.StoredProcedure;
saveCmd.Parameters.Add("@userid", SqlDbType.NVarChar).Value = id;
saveCmd.Parameters.Add("@course", SqlDbType.NVarChar).Value = course;
saveCmd.ExecuteNonQuery();
myCon.Close();
}
aspx.cs code
using ClassLibrary1;
Class1 cs = new Class1();
protected void Button1_Click(object sender, EventArgs e)
{
cs.assignofclass(TextBox1.Text, DropDownList1.SelectedValue);
Response.Write("<script> alert('" + TextBox1.Text +
DropDownList1.SelectedValue + "')</script>");
//just to make sure the textbox1 and dropdownlist1 is not giving
a null value
}
and lastly, the stored procedure
ALTER PROCEDURE dbo.assignclass
@userid nchar(10),
@course nchar(10)
AS
Update users Set
course = @course
Where userid = @userid
RETURN
what seems to be the problem here? i cant seem to update my table, btw
this is the table
Table name: users
userid nchar(10)
firstname nchar(20)
middlename nchar(20)
lastname nchar(20)
course nchar(10)
usertype nchar(10)
apassword nchar(20)
grade decimal(18, 2)
No comments:
Post a Comment