Hi I new here I have a couple of questions.
I am trying to authenticate login and password and Im getting a few errors.

1. first is the db error in my dbqueries class file. I am using sqlce for testing purposes.

public DataSet Login(string Username, string Password)
        {


            SqlCeConnection con = new SqlCeConnection("DataSource = CloakWare.sdf;");
            con.Open();
           
            SqlCeCommand cmd = new SqlCeCommand("Select * From Users where Username = @Username and Password = @Password");
            cmd.Connection = con;

            SqlCeDataAdapter da = new SqlCeDataAdapter("Select * From Users where Username = @Username and Password = @Password", con);
          
            cmd.Parameters.Add("@Username", SqlDbType.NVarChar, 100, "Username").Value = Username;
            cmd.Parameters.Add("@Password", SqlDbType.NVarChar, 100, "Password").Value = Password;
            DataSet ds = new DataSet();
            
            da.Fill(ds);    
          
            con.Close();

            return ds;
        }

this is the error it gives me : A parameter is missing. [ Parameter ordinal = 2 ]

I assume ordinal means position?

You add the parameters to the cmd object but then use the da object to execute the query. What's the purpose of the cmd object when you aren't using it?

i was trying them both out but this isnt the reason why its not working.

i did post the code, its the first post. When the debugger gets to da.fill(ds) it errors with a parameter is missing. [ Parameter ordinal = 2 ]

Because, as I said before, you are never setting the parameter. You are setting parameters on the cmd object not the da object.

oh i hear you but there doesnt seem to be an "addparameter" method for the dataadaptor.

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