请教各位大虾,怎样用ASP.NET写一个文本框和按钮?
    要求是在   点击   按钮后,文本框中的信息会直接添加到数据库中

解决方案 »

  1.   

    要在按钮的click事件中写代码
      

  2.   

    调用SQL语句或存储过程,就可以将数据保存到数据库了。
      

  3.   

    能具体些吗?谢谢,我是刚接触ASP.NET的
      

  4.   

    当然要先建立一个数据库了,textBox1.text和你的“字段名”要一一对应了,期间要使用DataSet或SqlCommand,我看还是用后者吧。
      

  5.   

        string connstr ;
    connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data ";
    connstr = connstr +"Source=" +this.MapPath("data//zhou.mdb") +";User ID=admin;Jet OLEDB:Database Password=123456" ;
              System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connstr);
                conn.Open(); string commstr = "Insert Into Tbl_News (Title,name,Status,Dt,Content) values (@Title,@name,@Status,@Dt,@Content)";
    System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand(commstr,conn);     System.Data.OleDb.OleDbParameter pTitle = new OleDbParameter("@Title",OleDbType.VarChar,100);
    pTitle.Value = tbTitle.Text.Trim();
    comm.Parameters.Add(pTitle); OleDbParameter pName = new OleDbParameter("@name",OleDbType.VarChar,100);
    pName.Value = tbName.Text.Trim();
    comm.Parameters.Add(pName);

    OleDbParameter pStatus = new OleDbParameter("@Status",OleDbType.Integer,0);
    pStatus.Value = ddlType.SelectedIndex;
    comm.Parameters.Add(pStatus); OleDbParameter pDt = new OleDbParameter("@Dt",OleDbType.Date,0);
    pDt.Value = DateTime.Parse(tbDt.Text);
    comm.Parameters.Add(pDt); OleDbParameter pContent = new OleDbParameter("@Content",OleDbType.VarChar,4000);
    pContent.Value = tbContent.Text;
    comm.Parameters.Add(pContent); comm.ExecuteNonQuery(); conn.Close();
      

  6.   

    用C#可以吗?
    添加到SQLserver中,按钮静态、动态无所谓,只要能将信息直接写道数据库中就可