我试图从DB接收一个整数值(vehicle_number)到一个文本框,自动填充框...我该怎么办?请
using (OdbcConnection conexao = new OdbcConnection(con))
{
OdbcCommand commandResgVei = new OdbcCommand(textoResgataVeiculo, conexao);
conexao.Open();
OdbcDataReader result = commandResgVei.ExecuteReader();
resultado.Read();
vehicle_number.Text = ?????????????????????????? // how?
name.Text = result["name"] as string;
}
答案 0 :(得分:0)
while(rdr.Read())
{
text = rdr["<name>"].ToString();
}
如果你真的需要解析它,那么你可以尝试:
reader.GetInt32(/*index*/);
或:
Int32.TryParse(text, out parsedInt)
答案 1 :(得分:0)
试试这个
vehicle_number.Text = result["vehicle_number"]!=null? convert.toString(
result["vehicle_number"]):"";
答案 2 :(得分:0)
vehicle_number.Text = result["vehicle_number"] as string;
答案 3 :(得分:0)
尝试一下
vehicle_number.Text=reader.GetInt32(index);