0

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?

2
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by AlBars
0

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?

0

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

0

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 ]

0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.