从表TABLE中读TEST字段出来,怎么显示到TEXTBOX控件上

解决方案 »

  1.   

    sqlselectstring="select Test from table where 字段ID='"+...+"'";//查询语句......
    ...
    sqldataReader myreader=cmd.extuceReader()
    textbox.text=myreader["Test"].tostring();
      

  2.   

    在form里添加一个textbox控件代码里 textbox名称.Text = "内容";
    - -!!!你的问题不是这样的吧??
      

  3.   

    Delphi 的Edit控件使用Caption作为输入输出口。.Net的TEXTBox是用Text。还有,如果你才开始作,你可以用控件来完成数据连结,操作跟D一样。。只要你具备ADO的知识即可。
      

  4.   

    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                aa();
            }
        }    protected void aa()
        {
            string settings = Convert.ToString(ConfigurationManager.ConnectionStrings["SqlConn"]);
            SqlConnection myconn = new SqlConnection(settings);
            myconn.Open();        SqlCommand cm = new SqlCommand("select TypeName from Departype where id=' + this.TextBox2.Text + ", myconn);
            SqlDataReader aa = cm.ExecuteReader();
            aa.Read();
            TextBox1.Text = aa["TypeName"].ToString();
            myconn.Close();
        }
        protected void Button1_Click1(object sender, EventArgs e)
        {
            string settings = Convert.ToString(ConfigurationManager.ConnectionStrings["SqlConn"]);
            SqlConnection myconn = new SqlConnection(settings);
            myconn.Open();
            SqlCommand cm = new SqlCommand("update Departype set TypeName='" + this.TextBox1.Text + "' where TypeNumber=' + this.TextBox2.Text + ", myconn);
            cm.ExecuteNonQuery();
            myconn.Close();
            Response.Redirect(Request.Url.ToString());
        }
    }麻烦看看这段错哪了,怎么报错
      

  5.   


    少了个单引号。  this.TextBox2.Text+"'",myconn);
      

  6.   

    TextBox1.Text = aa["TypeName"].ToString();报的错是这个错,说在没有任何数据时进行无效的读取
      

  7.   

    应该是这样
    SqlCommand cm = new SqlCommand("select TypeName from Departype where id='" + this.TextBox2.Text + "'", myconn); 

    SqlCommand cm = new SqlCommand("update Departype set TypeName='" + this.TextBox1.Text + "' where TypeNumber='" + this.TextBox2.Text + "'", myconn); 
      

  8.   

    是不是表中没有数据啊
    while(aa.read())
    {
      TextBox1.Text = aa["TypeName"].ToString(); 
    }
      

  9.   

    我只觉得TextBox不能在属性编辑器上直接绑定非类型化数据集的字段,不是太爽
    不过,我经常把字段填到tag中,然后循环绑定
      

  10.   

    我想在TextBox2中输入查询条件,然后在TextBox1中显示,应该怎么写?
    就是在TextBox2中输入查询条件,然后Button1查询,结果在TextBox1中显示出来
    希望谁能给出完整的代码,非常感谢
      

  11.   

    上面说的都对,谢谢你们了。就是我的代码自己都看不懂在干什么,能编译过。
    谁能说说:
    我想在TextBox2中输入查询条件,然后在TextBox1中显示,应该怎么写? 
    就是在TextBox2中输入查询条件,然后Button1查询,结果在TextBox1中显示出来 
    希望谁能给出完整的代码,非常感谢
      

  12.   

    以前工作需要的时候弄了会Dephi的,感觉比C#操作难些嘛。你的控件绑定是直接绑的吧~~~