Stored procedure
-
hi i have created stored procedure as follows:
ALTER PROCEDURE dbo.StoredProcedure1
(
@ID varchar(50),
@PassWord varchar(50),
@confirmPassword varchar(50),
@EmailID varchar(50)
)
AS
/* SET NOCOUNT ON */
insert into Login(ID,Password,ConfirmPassword,EmailID)Values(@ID,@PassWord,@ConfirmPassWord,@EmailID)
RETURNthen i have used this storedprocedure in coding as.Actually m tryin to submit a form containing id,password,conformpassword,email in table named Login:the code is:
public partial class emplogin : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Jajaipur"].ConnectionString);
SqlCommand cmd=new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{} protected void Button1\_Click(object sender, EventArgs e) { SqlParameter ID = new SqlParameter(); SqlParameter Password = new SqlParameter(); SqlParameter Confirm = new SqlParameter(); SqlParameter Email = new SqlParameter(); cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value=txtid.Text; cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value=txtpassword.Text; cmd.Parameters.Add("@Confirm", SqlDbType.VarChar).Value=txtconfirmpassword.Text; cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value=txtemailid.Text; cmd = new SqlCommand("StoredProcedure1",conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); txtid.Text=""; txtpassword.Text=""; txtemailid.Text=""; txtconfirmpassword.Text=""; }
}
i got this error on rub time:Procedure or function 'StoredProcedure1' expects parameter '@ID', which was not supplied. plz tell me wr m i wrong....
-
hi i have created stored procedure as follows:
ALTER PROCEDURE dbo.StoredProcedure1
(
@ID varchar(50),
@PassWord varchar(50),
@confirmPassword varchar(50),
@EmailID varchar(50)
)
AS
/* SET NOCOUNT ON */
insert into Login(ID,Password,ConfirmPassword,EmailID)Values(@ID,@PassWord,@ConfirmPassWord,@EmailID)
RETURNthen i have used this storedprocedure in coding as.Actually m tryin to submit a form containing id,password,conformpassword,email in table named Login:the code is:
public partial class emplogin : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Jajaipur"].ConnectionString);
SqlCommand cmd=new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{} protected void Button1\_Click(object sender, EventArgs e) { SqlParameter ID = new SqlParameter(); SqlParameter Password = new SqlParameter(); SqlParameter Confirm = new SqlParameter(); SqlParameter Email = new SqlParameter(); cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value=txtid.Text; cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value=txtpassword.Text; cmd.Parameters.Add("@Confirm", SqlDbType.VarChar).Value=txtconfirmpassword.Text; cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value=txtemailid.Text; cmd = new SqlCommand("StoredProcedure1",conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); txtid.Text=""; txtpassword.Text=""; txtemailid.Text=""; txtconfirmpassword.Text=""; }
}
i got this error on rub time:Procedure or function 'StoredProcedure1' expects parameter '@ID', which was not supplied. plz tell me wr m i wrong....
Ok. Short version: move this line:
cmd = new SqlCommand("StoredProcedure1",conn);
to the top of your method. Longer version: read up on collections. [edit]sorry, wrong line[/edit]
mylogics wrote:
i got this error on RUB time
I know it was a typo, but soooo funny ;)
var question = (_2b || !(_2b));
-
Ok. Short version: move this line:
cmd = new SqlCommand("StoredProcedure1",conn);
to the top of your method. Longer version: read up on collections. [edit]sorry, wrong line[/edit]
mylogics wrote:
i got this error on RUB time
I know it was a typo, but soooo funny ;)
var question = (_2b || !(_2b));
-
Look man, it wont give an error, alright? Please read my edited post. You were adding to a collection of an object and then you constructed it again, therefore losing all previously assigned properties. Move that line to before you're starting to add parameters and all will be well. Believe me.
var question = (_2b || !(_2b));
-
change the code as blow.... protected void Button1_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("StoredProcedure1",conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value=txtid.Text; cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value=txtpassword.Text; cmd.Parameters.Add("@Confirm", SqlDbType.VarChar).Value=txtconfirmpassword.Text; cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value=txtemailid.Text; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); txtid.Text=""; txtpassword.Text=""; txtemailid.Text=""; txtconfirmpassword.Text=""; }
-
Look man, it wont give an error, alright? Please read my edited post. You were adding to a collection of an object and then you constructed it again, therefore losing all previously assigned properties. Move that line to before you're starting to add parameters and all will be well. Believe me.
var question = (_2b || !(_2b));