blishman Posted October 26, 2006 Share Posted October 26, 2006 Ok so here is whats happening: my job is to take a MySQL database and update it regularly using c#...the problem comes when I have to insert new rows to the table. Using the OdbcDataAdapter, i build the mySQL data into a table, run the update algorithm, which in the current case adds 72 rows to it. I then try to update it back in by building the insert commands one at a time to add the new rows into the mySQL table, but the problem is that for each time i call the adapter.Update() function, it inserts 72 rows using the value i specify...so that the table looks like this:newcomp1 value value valuenewcomp1 value value value... (70 more times)newcomp2 value value valuenewcomp2 value value valuehere is the code for that portion:complete is the final dataset that contains the machines table's updatemachines not used in the complete.tables context is the name of the table on the mysql serveradapter is the OdbcDataAdaptermax2 is the size of the original tablemax is the size of the updated table for (int j = max2; j < max; j++) { String InsertString = "INSERT INTO machines (machine_name, boot_os, harddrive_size, ram_size, proc_speed) VALUES"; InsertString += "(\"" + complete.Tables["machines"].Rows[j]["machine_name"].ToString() + "\",\"" + complete.Tables["machines"].Rows[j]["boot_os"].ToString() + "\"," + complete.Tables["machines"].Rows[j]["harddrive_size"].ToString() + "," + complete.Tables["machines"].Rows[j]["ram_size"].ToString() + "," + complete.Tables["machines"].Rows[j]["proc_speed"].ToString() + ");"; OdbcCommand insrt = new OdbcCommand(InsertString, test_connection); adapter.InsertCommand = insrt; adapter.Update(complete, "machines"); }any advice would be greatly appreciated, my email is [email protected] or my msn messenger is [email protected] Link to comment https://forums.phpfreaks.com/topic/25190-c-and-mysql-problem/ Share on other sites More sharing options...
fenway Posted October 26, 2006 Share Posted October 26, 2006 I'm not familiar with this wrapper class.. but it sounds like you're in the for loop too many times. Link to comment https://forums.phpfreaks.com/topic/25190-c-and-mysql-problem/#findComment-114936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.