urgent please help

B

bbawa1

I have the following code but when I build this it gives me errors
that username, userpass, userfname does not exist in current context.
I don't know where is the problem and how can I fix this.


SqlConnection objConn = new SqlConnection("Data
Source=sql1300.mssqlservers.com;Initial Catalog=twcsan;Persist
Security Info=True;User ID=twcsan;Password=mln0531");

SqlCommand objCmd = new SqlCommand("UPDATE tbUsers SET
MyName = @username, " +
"MyPass = @userPass, " +
"UserFName = @userfname, " +
"WHERE UserId = 10", objConn);
objConn.Open();
objCmd.Parameters.AddWithValue(@username1, TextBox1.Text);
objCmd.Parameters.AddWithValue(@userPass,
this.TextBox2.Text);
objCmd.Parameters.AddWithValue(@userfname,
this.TextBox3.Text);


objCmd.ExecuteNonQuery();
objConn.Close();


Thanks in advance
 
E

Evan M.

I have the following code but when I build this it gives me errors
that username, userpass, userfname does not exist in current context.
I don't know where is the problem and how can I fix this.

SqlConnection objConn = new SqlConnection("Data
Source=sql1300.mssqlservers.com;Initial Catalog=twcsan;Persist
Security Info=True;User ID=twcsan;Password=mln0531");

SqlCommand objCmd = new SqlCommand("UPDATE tbUsers SET
MyName = @username, " +
"MyPass = @userPass, " +
"UserFName = @userfname, " +
"WHERE UserId = 10", objConn);
objConn.Open();
objCmd.Parameters.AddWithValue(@username1, TextBox1.Text);
objCmd.Parameters.AddWithValue(@userPass,
this.TextBox2.Text);
objCmd.Parameters.AddWithValue(@userfname,
this.TextBox3.Text);

objCmd.ExecuteNonQuery();
objConn.Close();

Thanks in advance

Within the AddWithValue function, enclose your parameter names in
quotes:
objCmd.Parameters.AddWithValue("@username", TextBox1.Text);
 
B

bbawa1

Within the AddWithValue function, enclose your parameter names in
quotes:
objCmd.Parameters.AddWithValue("@username", TextBox1.Text);- Hide quoted text -

- Show quoted text -

Thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top