Update data on SQLDB from TextBox.

D

Dmitri

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top