Good Afternoon All

i think its Firday fever, am tired. I think this Happens sometimes. let me get to the Problem. Am doing an OleDb Project

I have an Access DB and the table is Users , here are the Field and dataType

ID = Autonumber(int)
Firstname = TEXT
LastName = TEXT
Username = TEXT
Password = TEXT
Email = TEXT

Now i have a Function that inserts into these Field from my DAL that is Written like this

public int Register_User(String Firstname, String LastName, String Username, String Password, String Email)
            int Res=0;
            con = new OleDbConnection(strcon);

            cmdinsert = new OleDbCommand();

            cmdinsert.CommandText = "insert into Users Values(?,?,?,?,?)";

            cmdinsert.CommandTimeout = 0;

            cmdinsert.CommandType = CommandType.Text;

            cmdinsert.Connection = con;

            cmdinsert.Parameters.Add("Username", OleDbType.VarChar,30).Value = Convert.ToString(Username);

            cmdinsert.Parameters.Add("Password", OleDbType.VarChar,30).Value = Convert.ToString(Password);

            cmdinsert.Parameters.Add("Firstname", OleDbType.VarChar,30).Value = Convert.ToString(Firstname);

            cmdinsert.Parameters.Add("LastName", OleDbType.VarChar,30).Value = Convert.ToString(LastName);

            cmdinsert.Parameters.Add("Email", OleDbType.VarChar, 30).Value = Convert.ToString(Email);


                Res =(int) cmdinsert.ExecuteScalar();

            catch (OleDbException)
                 return Res;

When i try to insert , i get an Exception.

Number of query values and destination fields are not the same.

Can you please Point the Problem for me

Thank you :)

This article has been dead for over six months. Start a new discussion instead.