| | |
how do i update to Access db?
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2005
Posts: 38
Reputation:
Solved Threads: 1
hi
im using VS .net, MS Access and c# language.
basically i tried to do an update command using oleDbDataAdapter and commandbuilder. i also searched for tutorials but i still cant get things going.
could someone please tell me how come i couldnt generate update and delete commands using oleDbDataAdapter? i managed to do select command and my parameterized query is working well.
i just want to do an update now. what other ways are there for me to do this and also ensure that the changes return correctly to the place that i queried from?
if possible, i hope i can do this in IDE instead of programmatically.
as im a novice, please pardon me and help me with some step by step instructions whenever possible. thank you.
are there any simple walkthrough tutorials that i can follow to accomplish my entire update task? i appreciate it if you could provide me with sample codes or just anything helpful. time's running out... hope to get update going asap..
thanks a lot to all of you! =)
im using VS .net, MS Access and c# language.
basically i tried to do an update command using oleDbDataAdapter and commandbuilder. i also searched for tutorials but i still cant get things going.
could someone please tell me how come i couldnt generate update and delete commands using oleDbDataAdapter? i managed to do select command and my parameterized query is working well.
i just want to do an update now. what other ways are there for me to do this and also ensure that the changes return correctly to the place that i queried from?
if possible, i hope i can do this in IDE instead of programmatically.
as im a novice, please pardon me and help me with some step by step instructions whenever possible. thank you.
are there any simple walkthrough tutorials that i can follow to accomplish my entire update task? i appreciate it if you could provide me with sample codes or just anything helpful. time's running out... hope to get update going asap..
thanks a lot to all of you! =)
Greetings:
Actually i spent a lot of time trying to do this with the default updateCommand, but, with no satisfactory results, my suggestion is to use sql commands with an OleDbCommand, what you need is to check if there was an update and if so enter a sql instruction:
This is the easy way, overwrite all of them with the new stored values, the beauty of this is that you also insert new records, the problem is that you first need to check that the values are valid and you are not changing protected values, if you want to do it correctly just check wich of the fields was changed by comparing your object (in this case linea) to the db and just change where they don`t match.
Hope this helps and sorry for my bad English, it`s not my native language :o
Actually i spent a lot of time trying to do this with the default updateCommand, but, with no satisfactory results, my suggestion is to use sql commands with an OleDbCommand, what you need is to check if there was an update and if so enter a sql instruction:
•
•
•
•
if(myDataSet.HasChanges()){
DataTable update=new DataTable("name of your table");
update=contenedor.Tables[0];
int len=0;
//Check the length of the table rows
foreach(DataRow myRow in update.Rows)
{
len++;
}
conexion.Open();
for(int i=lenI;i<len;i++)
{
Object linea=update.Rows[i].ItemArray;
comandos1=new OleDbCommand("INSERT INTO tabla1"+" VALUES ("+linea[0]+","+linea[1]+","+linea[2]+")",conexion);
comandos1.ExecuteNonQuery();
}
conexion.Close();
}
Hope this helps and sorry for my bad English, it`s not my native language :o
•
•
Join Date: Jul 2005
Posts: 38
Reputation:
Solved Threads: 1
oh i see... i can do multiple row updates now...
to take this to a higher level, how do i update multiple rows for ALL of the tables in my Access database?
right now, i only can update multiple rows for a table... so i have no choice but to update tables one by one...
i use dataadapter to generate update commands. using dataadapter i can only select one table to write my SQL codes. how can i update all my tables at one go then??
to take this to a higher level, how do i update multiple rows for ALL of the tables in my Access database?
right now, i only can update multiple rows for a table... so i have no choice but to update tables one by one...
i use dataadapter to generate update commands. using dataadapter i can only select one table to write my SQL codes. how can i update all my tables at one go then??
Greetings:
You could use a loop for the number of the table on your DataTable to update all, there`s a way of updating all in one pass but i think this method gives you more control on the values that you pass to the database, other thing that i just realize is that in this part you could specify all of the tables and refer to them as you need them, but im not sure exactly how, as soon as i get home i`ll give it a go
You could use a loop for the number of the table on your DataTable to update all, there`s a way of updating all in one pass but i think this method gives you more control on the values that you pass to the database, other thing that i just realize is that in this part
•
•
•
•
DataTable update=new DataTable("name of your table");
update=contenedor.Tables[0];
![]() |
Similar Threads
- how to update an access DB with vb.net? (ASP.NET)
- Updating Access Db Using Vb.net 2005 (VB.NET)
- Need help from the pro's (can't access symantec, amazon.com, etc...) (Viruses, Spyware and other Nasties)
- Program update problem (Windows Software)
Other Threads in the C# Forum
- Previous Thread: Text printing is giving me trouble
- Next Thread: Need help in Paging
| Thread Tools | Search this Thread |
.net access algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom customactiondata database datagrid datagridview dataset datastructure date/time datetime datetimepicker degrees development dll draganddrop drawing encryption enum event excel file filename files form format forms function gdi+ gis gtk hash image index input install java label list listbox mandelbrot math mouseclick mysql operator outlook2003 path photoshop picturebox pixelinversion pixelminversion post programming radians regex remoting richtextbox safari server sleep snooze socket sql statistics stream string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser webcam wia windows winforms wpf xml





