SqlDataAdapter adp = new SqlAdapter("select [name] from Employee where id=001", Conn);
DataSet dt = new DataSet();
adp.Fill(dt, "Employee");
if (dt.Tables["Employee"].Rows.Count > 0)
{
   textBox1.Text = dt.Tables["Employee"].Rows[0]["name"].ToString();
}
dt.Tables["Employee"].Clear();

解决方案 »

  1.   

    System.Data.OleDb.OleDbDataAdapter  odd=new OleDbDataAdapter("select name from Employee where  id=001 ",this.cnn);
     DataTable table=new DataTable();
               odd.Fill(table);
             this.TextBox1.text=table.Rows[0][0].ToString();
      

  2.   

    mycon = new OleDbConnection(cnn);
    mycon.Open();
    OleDbCommand command = mycon.CreateCommand(); //创建Command对象
    command.CommandText = "Select * From terminal where terminal_name = '"+strID+"'";
    OleDbDataReader myReader = command.ExecuteReader();
    myReader.Read();
    this.txtName.Text = myReader.GetString(2); //名称
    this.txtId.Text = myReader.GetString(0);
    this.txtAddress.Text = myReader.GetString(1);
    this.cbozt.Text = myReader.GetString(23);
    this.dateTimePicker.Text = myReader.GetString(12);
    this.txtFalg1.Text = myReader.GetByte(21).ToString();
    this.txtFalg2.Text = myReader.GetByte(22).ToString();
    this.txtAVA.Text = myReader.GetString(5);
    this.txtBVA.Text = myReader.GetString(6);
    this.txtCVA.Text = myReader.GetString(7);
    this.txtAVI.Text = myReader.GetString(8);
    this.txtBVI.Text = myReader.GetString(9);
    this.txtCVI.Text = myReader.GetString(10);
      

  3.   

    已经解决了,谢谢!
    还想再问一下,我想将TextBox1中的值与TextBox2中的值相乘后把值赋给TextBox3,又该如何做?
      

  4.   

    我是这样做的。
    TextBox3.text=Convert.tostring(Convert.toDecimal(TextBox1.text)*Convert.toDecimal(TextBox2.text));
    我这样等到的是错误的,请问我错在哪儿?
    应该怎么改?
    谢谢!!
      

  5.   

    你用deciaml.para...进行转化!然后进行操作。再赋给TextBox3
      

  6.   

    zse3(吴琳)
    谢谢!可以再讲详细一点吗?