phani
August 7, 2016, 7:23am
1
this is my querry in the c#
string ssql= "insert into register(fname,lname,username,userpwd) values('" + fn +"', '" + ln + "', '" + uname + "', " + pwd + ")";
in db first two or char and other are varchar and the problem is i am facing is while i am inserting the data it is showing pwd input is invalid column name.
Nelson
August 7, 2016, 1:22pm
2
With EF, try something like this, much better.
public void AddUser()
{
User newUser = new User;
newUser.fname = txtFname.Text;
newUser.lname = txtLname.Text;
newUser.username = txtUsername.Text;
newUser.password = txtPassword.Text;
UserDAL.Insert(newUser);
}
public class UserDAL
{
public static void Insert(User user)
{
using (var context = new DBEntities())
{
context.User.Add(user);
context.SaveChanges();
}
}
}
You forgot to add single quote at the last variable ('). It should be -
string ssql= "insert into register(fname,lname,username,userpwd) values('" + fn +"', '" + ln + "', '" + uname + "', '" + pwd + "')";
system
Closed
November 12, 2016, 6:14pm
4
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.