Click here to Skip to main content
15,905,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to update data using dataset and dataadapter.. code for editing data to the database is as follows.. but it is not working.
C#
try
            {
                MAconn = new OleDbConnection();
                MAconn.ConnectionString = connectionString;
                MAconn.Open();
                DataSet oDS = new DataSet();
                string query = "SELECT * FROM info";
 
                OleDbDataAdapter oOrdersDataAdapter = new OleDbDataAdapter(query, connectionString);
 
                OleDbCommandBuilder oOrdersCmdBuilder = new OleDbCommandBuilder(oOrdersDataAdapter);
 
                oOrdersDataAdapter.Fill(oDS);
 
                DataTable pTable = oDS.Tables["Table"];
                pTable.TableName = "info";
 
                // edit data ( main code goes from here)
                
                DataRow oOrderRow = oDS.Tables["info"].Rows.Find("textbox1.Text"); 
                oOrderRow["cell"]= "txtcell.Text";
                
               
                oOrdersDataAdapter.Update(oDS, "info");
                MessageBox.Show("deleted");
            }
            catch (Exception ex)
            { MessageBox.Show("some prob" + ex); }


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 1-May-11 7:13am
v4
Comments
codegeekalpha 1-May-11 9:06am    
pls help me i am waiting from the last 1 and a half hour
thatraja 1-May-11 13:14pm    
/*but it is not working*/
what do you mean? you got any error message? if yes then include that in your question.
codegeekalpha 1-May-11 15:09pm    
i have done it my self..
thx everyone kindly delete that question..
Ashishmau 2-May-11 2:06am    
see, ur select query is wrong as ur selecting from excel.
it should be
select * from [info$]

1 solution

use command object in dataadapter. i think you had done opposite
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900