Click here to Skip to main content
13,596,321 members
Rate this:
Please Sign up or sign in to vote.
See more:
How can i updata data in the textbox and them with a"save" button.. to save this changes again in the sql database.

I have tried this one:
How can i specify in the where condition, the row index??
OleDbCommand myComm = new OleDbCommand("UPDATE Customer SET Code='" + txt_code.Value + "', Description='"+txt_desc.Value+ "', DescLong = '" + txt_longdesc.Value+ "', Tel='"+txt_tel.Value+ "', Mobile = '" + txt_mobile.Value+ "' ,  WHERE ????=" + ????+ , con );
Posted 26-Nov-12 0:52am
Updated 26-Nov-12 4:02am
faisal23 26-Nov-12 7:30am
What do you mean by update data in textbox it is already editable. And save button write simple update query
lovitaxxxx 26-Nov-12 7:47am
how to specify the row index of the datatable i am in a specific moment?
How are you showing these customer details in front-end (in a grid or table or using what) ?
lovitaxxxx 26-Nov-12 16:05pm
in a textbox i retrieve data from the datatable
So, if you are retrieving data from DatatTable, then can you show that code please ?
I need to see how exactly you get data and show in textbox.
lovitaxxxx 27-Nov-12 4:32am
<pre> protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)
con = new OleDbConnection();
con.ConnectionString = "Provider=SQLOLEDB; Data Source=; Initial Catalog=; User ID=; Password=";
ds = new DataSet();

string sql = "SELECT * From Customer";

da = new OleDbDataAdapter(sql, con);

da.Fill(ds, "Customer");
MaxRows = ds.Tables["Customer"].Rows.Count;


private void navigo()

txt_code.Value = ds.Tables["Customer"].Rows[count]["Code"].ToString();
txt_desc.Value = ds.Tables["Customer"].Rows[count]["Description"].ToString(); </pre>
lovitaxxxx 27-Nov-12 4:32am
I dont know how to update this data by specifying the row index I am navigating in a specifis moment :/
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

on the click of save button write dowo following code

 cmd=new SQlcommand("update tablename set columnname='"+textbox.text +"' where id='"+id+"'",con);;

where con is connection object
cmd in sqlcommand object
id is the primary key for which row you want to update
lovitaxxxx 26-Nov-12 7:45am
I have created a navigation system.. using last, first, next, previews buttons
And how cn i specify the row index in the update sql query?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Assuming you want to know how to save the data in DB, This could be useful for you: A Beginner's Tutorial for Understanding ADO.NET[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.180621.3 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100