0
public List Select() { List ListaCaminhao = new List();
SqlConnection conexao = new SqlConnection(strCon);
string sql = "Select * from Caminhao;";
SqlCommand cmd = new SqlCommand(sql, conexao);
conexao.Open();
try
{
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
Model.Caminhao caminhao = new Model.Caminhao();
caminhao.IDCaminhao = Convert.ToInt32(reader[0].ToString());
caminhao.IDMotorista = convert.ToInt32(reader["IDMotorista"].ToString());
This second reader["IDMotorista"]
is my secondary key, is the id I want to show the name.
Is the same question? http://answall.com/q/120793/91
– rray