Hi all,
How do i retrieve the ID value of a specific column? Lets say i have a database called user.db with two tables, one called check_details and check_pins.
lets say check details has the following columns: x_id, username, email, fullname, department
and the second table has the following columns: id, primarypin, secondarypin
Now i run an application that pulls the users 'username' from his PC and queries sql for all the columns data.
The problem i have is that i don't know the 'username's' id so i cant query both tables for the data.
How would i obtain both tables's id and x_id?
public EQData()
{
SQLConnect sqlcon = new SQLConnect();
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("select x_id, fullname, email, name, primarypin, secondarypin FROM cas_user_ext, cat_validation WHERE x_id = @key AND id = @key",
sqlcon.Connection);
myCommand.Parameters.AddWithValue("@key", "501");
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
x_id = myReader["x_id"].ToString();
fullname = myReader["fullname"].ToString();
email = myReader["email"].ToString();
name = myReader["name"].ToString();
primarypin = myReader["primarypin"].ToString();
secondarypin = myReader["secondarypin"].ToString();
}
sqlcon.Close();
}
}
}
This is the class i have created that's working but only if i manually add the @key value. Any assistance would be appreciated. I have read up on the identity commands but i don't know how to implement it to my code.