EDN Admin
Well-known member
Hi all ,
I have a query which has three paramters which should be passed to retrieve the password if the user forgot
Here is the code which I wrote ,
This happens on click button event here when I run this the error was @username is not declared if I change the SQL query to
select User_password from table where username=@username
here @username=textbox1.text;
it worked if I want to satisfy three paramters
select user_password from table where mailto:username=@username username=@username and
mailto:securityquestion=@security securityquestion=@security and mailto:securityanswer=@answer
securityanswer=@answer
@username=textbox1.text;
@securityquestion=textbox2.text;
@securityanswer=textbox3.text;
But I was unable to pass more than one parameter at a time. to satisfy my query.
<pre class="prettyprint SqlConnection Con = new SqlConnection
("Data Source=3Z3CP4J;Initial Catalog=PharmacyPatientHistory;Integrated Security=true");
SqlCommand cmd = new SqlCommand();
cmd.Connection = Con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "declare @passowrd varchar(50) set @passowrd=(select User_Password from dbo.UserLogin where UserName in (@username) and User_Securtiy_Question in (@securityq)) select @passowrd as userpassword ";
Con.Open();
SqlParameter param = new SqlParameter();
param.ParameterName = "@username";
param.ParameterName = "@securityq";
param.Value = User;
param.Value = securityQuestion;
cmd.Parameters.Add(param);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string a = (string)reader[0];
textBox2.Text = a;
}
<br/>[/code]<hr class="sig Sri.Tummala
View the full article
I have a query which has three paramters which should be passed to retrieve the password if the user forgot
Here is the code which I wrote ,
This happens on click button event here when I run this the error was @username is not declared if I change the SQL query to
select User_password from table where username=@username
here @username=textbox1.text;
it worked if I want to satisfy three paramters
select user_password from table where mailto:username=@username username=@username and
mailto:securityquestion=@security securityquestion=@security and mailto:securityanswer=@answer
securityanswer=@answer
@username=textbox1.text;
@securityquestion=textbox2.text;
@securityanswer=textbox3.text;
But I was unable to pass more than one parameter at a time. to satisfy my query.
<pre class="prettyprint SqlConnection Con = new SqlConnection
("Data Source=3Z3CP4J;Initial Catalog=PharmacyPatientHistory;Integrated Security=true");
SqlCommand cmd = new SqlCommand();
cmd.Connection = Con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "declare @passowrd varchar(50) set @passowrd=(select User_Password from dbo.UserLogin where UserName in (@username) and User_Securtiy_Question in (@securityq)) select @passowrd as userpassword ";
Con.Open();
SqlParameter param = new SqlParameter();
param.ParameterName = "@username";
param.ParameterName = "@securityq";
param.Value = User;
param.Value = securityQuestion;
cmd.Parameters.Add(param);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string a = (string)reader[0];
textBox2.Text = a;
}
<br/>[/code]<hr class="sig Sri.Tummala
View the full article