Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Update data on SQLDB from TextBox.

Reply
Thread Tools

Update data on SQLDB from TextBox.

 
 
Dmitri
Guest
Posts: n/a
 
      11-08-2003
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.SqlDbT ype.Int);

myParam.Direction=ParameterDirection.Output;

SqlParameter myParam2 = new SqlParameter();

myParam2 =
myComm.Parameters.Add("@Body",System.Data.SqlDbTyp e.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;dat abase=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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update On The Windows Phone 7 Update Update Lawrence D'Oliveiro NZ Computing 2 02-25-2011 08:03 AM
why I can't update data, but I can insert data into new mode OnRails Ruby Ruby 2 10-19-2007 11:49 PM
ajax image data fetch, javascript IMG data update? Marcus Javascript 2 12-08-2006 04:51 PM
Creating an SQLDB search using a stored procedure Matthew Curiale ASP .Net 1 02-11-2005 04:08 PM
[Vb.net question] how to apply online update function into program (the effect just like Norton system work live update) chan ASP .Net 1 03-04-2004 02:58 PM



Advertisments