str="select * from table"
 myreader=new sqldatareader(str,myconn)
  if myreader.read then
   txt_name.text=myreader.item("name")
   .....
  end if
 myreader.close

解决方案 »

  1.   

    str="select * from table wher name="name""
     myreader=new sqldatareader(str,myconn)
      if myreader.read then
       txt_name.text=myreader.item("name")
       .....
      end if
     myreader.close
    ok!!!!!!!!!!!!!!
    通过Name查询其他的内容
      

  2.   

    dim cn as new sqlconnection(strconnectiong)
    str="select * from table where name='" & txtname.text
    dim  cmd as new sqlcommand(str,cn)
    dim myreader as sqldatareader
    myreader=cmd.executereader(commandbehavior.closeconnection)
      if myreader.read then
       txt_name.text=myreader.item("name")
       .....
      end if
     myreader.close
      

  3.   

    '有点错误
    dim cn as new sqlconnection(strconnectiong)
    str="select * from table where name='" & txtname.text & "'"
    dim  cmd as new sqlcommand(str,cn)
    dim myreader as sqldatareader
    myreader=cmd.executereader(commandbehavior.closeconnection)
      if myreader.read then
       txt_name.text=myreader.item("name")
       .....
      end if
     myreader.close
      

  4.   

    SqlConn.Open();
    string str = "select * from YourTable";
    SqlCommand cmd = new SqlCommand(str,SqlConn);
    SqlDataReader dr = cmd.ExecuteReader();
    if(dr.Read())
    {
    this.textbox1.text=dr["ID"].ToString();
    this.textbox2.text=dr["NAME"].ToString();
    this.textbox3.text=dr["Company"].ToString();
    this.textbox4.text=dr["Phone"].ToString();
    this.textbox5.text=dr["Birthday"].ToString();
    dr.Close();
    }
    cmd.Cancel();
    SqlConn.Close();
      

  5.   

    string str="select * from table where Name='"+this.textbox.text+"'";
      

  6.   

    你肯定你的返回记录是一条吗??如果多条的话 最好使用datagrid