Update data on SQLDB from TextBox.

Discussion in 'ASP .Net Web Controls' started by Dmitri, Nov 8, 2003.

  1. Dmitri

    Dmitri Guest

    Hi all.

    I have TextBox, when Page Loading TextBox fill data from DB. I'am do any
    change and click save. When i click save i'am connect to Db and update data.

    When i'am use debuger i see what data contain my TextBox., it dosn't change!
    why?

    private void Page_Load(object sender, System.EventArgs e)

    {

    string ID=Request.QueryString["ID"];

    PostID=ID;

    string name=Server.HtmlEncode(User.Identity.Name);

    int verif=Verification(name,ID);

    if (verif==0)

    {

    Label1.Visible=true;

    TextBox1.ReadOnly=true;

    }

    else if(verif==1)

    {

    Label1.Visible=false;

    }

    }

    int Verification (string name,string ID)

    {

    SqlConnection myConn = new SqlConnection("Server=localhost;UID=sa
    PWD=123;database=support");

    SqlCommand myComm = new SqlCommand("support.fr_verification",myConn);

    myComm.CommandType = CommandType.StoredProcedure;

    myComm.Parameters.Add("@ID",ID);

    myComm.Parameters.Add("@login",name);

    SqlParameter myParam = new SqlParameter();

    myParam = myComm.Parameters.Add("@result",System.Data.SqlDbType.Int);

    myParam.Direction=ParameterDirection.Output;

    SqlParameter myParam2 = new SqlParameter();

    myParam2 =
    myComm.Parameters.Add("@Body",System.Data.SqlDbType.VarChar,6000);

    myParam2.Direction=ParameterDirection.Output;

    myConn.Open();

    myComm.ExecuteNonQuery();

    string res=myComm.Parameters["@result"].Value.ToString();

    TextBox1.Text=myComm.Parameters["@Body"].Value.ToString();

    int result = Convert.ToInt32(res);

    myConn.Close();

    return(result);

    }

    public void UpdateData(object sender, System.EventArgs e)

    {

    String resp=Request.Url.AbsoluteUri;

    string Bodymessage=TextBox1.Text;

    SqlConnection myConn = new
    SqlConnection("Server=localhost;UID=sa;PWD=123;database=support");

    SqlCommand myComm = new SqlCommand("support.fr_updaterecord",myConn);

    myComm.CommandType = CommandType.StoredProcedure;

    myComm.Parameters.Add("@ID",PostID);

    myComm.Parameters.Add("@Body",Bodymessage);

    myConn.Open();

    myComm.ExecuteNonQuery();

    myConn.Close();

    Response.Redirect(resp);

    }



    Than you.
     
    Dmitri, Nov 8, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S. Justin Gengo
    Replies:
    0
    Views:
    543
    S. Justin Gengo
    Jul 16, 2003
  2. Hazzard
    Replies:
    2
    Views:
    558
    Yan-Hong Huang[MSFT]
    Jul 23, 2003
  3. Natty Gur
    Replies:
    0
    Views:
    467
    Natty Gur
    Jul 22, 2003
  4. Matthew Curiale
    Replies:
    1
    Views:
    374
  5. tanmaypatankar
    Replies:
    0
    Views:
    1,087
    tanmaypatankar
    Dec 18, 2007
Loading...

Share This Page