Click here to Skip to main content
Rate this: bad
good
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 1:52am
v2
Comments
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);
 
con.Open();
da.Fill(ds, "Customer");
navigo();
MaxRows = ds.Tables["Customer"].Rows.Count;
 

con.Close();
con.Dispose();
 
}
}
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
good
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);
con.open();
cmd.executeNonQUery();
con.close();
 
where con is connection object
cmd in sqlcommand object
id is the primary key for which row you want to update
  Permalink  
Comments
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
good
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[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 270
1 Sergey Alexandrovich Kryukov 185
2 BillWoodruff 173
3 CPallini 155
4 Kamal Rocks 144
0 OriginalGriff 5,655
1 DamithSL 4,506
2 Maciej Los 3,997
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2014
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