Click here to Skip to main content
11,805,310 members (63,847 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
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
faisal23 at 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
Annnaa at 26-Nov-12 7:47am
how to specify the row index of the datatable i am in a specific moment?
Tadit Dash at 26-Nov-12 10:05am
How are you showing these customer details in front-end (in a grid or table or using what) ?
Annnaa at 26-Nov-12 16:05pm
in a textbox i retrieve data from the datatable
Tadit Dash at 27-Nov-12 1:17am
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.
Annnaa at 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>
Annnaa at 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
Annnaa at 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
0 OriginalGriff 315
1 Sergey Alexandrovich Kryukov 210
2 Richard Deeming 200
3 CPallini 160
4 CHill60 150
0 OriginalGriff 3,265
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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