R
r
Trying to design a simple admin windows form app to update and insert from 2
MySQL tables.
I'm using the ByteFX dll which looks almost identical in function to the
native ODBC classes.
I'm able to connect and fill two data adapters with info from the MySQL
tables and display the results on 2 datagrids on my form but I'm lost in the
woods trying to figure out the best way to get the updates and inserts to
work.
I'd like to somehow get the changed info from the display grid into the
'haschanged' collection?, temp table? or something that I'm led to believe
exists somewhere...and just have the adapter's update command walk this row
collection? (or whatever it is) and send the data back to my database using
the update sql query I've defined.
I think I've got a vague idea of what's possible but I'm just lost figuring
out the how. This stuff seems very flexible and as a result, very complex.
Thanks for any tips. Here's a snip from my code:
mDataSetSlots= new DataSet();
DataAdapter_Slots=new MySqlDataAdapter();
SQL_Cmd_UpdateSlot = myConn.CreateCommand();
SQL_Cmd_UpdateSlot.CommandType=CommandType.Text;
SQL_Cmd_UpdateSlot.CommandText=
"UPDATE Slots SET" +
"JobID = @JobID," +
"stDate = @stDate," +
"TimeStart = @TimeStart," +
"TimeEnd = @TimeEnd," +
"Pool = @Pool," +
"Workers_Needed = @Workers_Needed," +
"Workers_Enlisted=@Workers_Enlisted" +
"where SlotID =@SlotID;";
DataAdapter_Slots.UpdateCommand=SQL_Cmd_UpdateSlot;
DataAdapter_Slots.UpdateCommand.Parameters.Add("@JobID", MySqlDbType.Short);
DataAdapter_Slots.UpdateCommand.Parameters.Add("@stDate",
MySqlDbType.Date,8,"stDate");
DataAdapter_Slots.UpdateCommand.Parameters.Add("@TimeStart",
MySqlDbType.VarChar,8,"TimeStart");
DataAdapter_Slots.UpdateCommand.Parameters.Add("@TimeEnd",
MySqlDbType.VarChar,8,"TimeEnd");
DataAdapter_Slots.UpdateCommand.Parameters.Add("@Pool",
MySqlDbType.VarChar,1,"Pool");
DataAdapter_Slots.UpdateCommand.Parameters.Add("@Workers_Needed",
MySqlDbType.Short,2,"Workers_Needed");
DataAdapter_Slots.UpdateCommand.Parameters.Add("@Workers_Enlisted",
MySqlDbType.Short,2,"Workers_Enlisted");
MySQL tables.
I'm using the ByteFX dll which looks almost identical in function to the
native ODBC classes.
I'm able to connect and fill two data adapters with info from the MySQL
tables and display the results on 2 datagrids on my form but I'm lost in the
woods trying to figure out the best way to get the updates and inserts to
work.
I'd like to somehow get the changed info from the display grid into the
'haschanged' collection?, temp table? or something that I'm led to believe
exists somewhere...and just have the adapter's update command walk this row
collection? (or whatever it is) and send the data back to my database using
the update sql query I've defined.
I think I've got a vague idea of what's possible but I'm just lost figuring
out the how. This stuff seems very flexible and as a result, very complex.
Thanks for any tips. Here's a snip from my code:
mDataSetSlots= new DataSet();
DataAdapter_Slots=new MySqlDataAdapter();
SQL_Cmd_UpdateSlot = myConn.CreateCommand();
SQL_Cmd_UpdateSlot.CommandType=CommandType.Text;
SQL_Cmd_UpdateSlot.CommandText=
"UPDATE Slots SET" +
"JobID = @JobID," +
"stDate = @stDate," +
"TimeStart = @TimeStart," +
"TimeEnd = @TimeEnd," +
"Pool = @Pool," +
"Workers_Needed = @Workers_Needed," +
"Workers_Enlisted=@Workers_Enlisted" +
"where SlotID =@SlotID;";
DataAdapter_Slots.UpdateCommand=SQL_Cmd_UpdateSlot;
DataAdapter_Slots.UpdateCommand.Parameters.Add("@JobID", MySqlDbType.Short);
DataAdapter_Slots.UpdateCommand.Parameters.Add("@stDate",
MySqlDbType.Date,8,"stDate");
DataAdapter_Slots.UpdateCommand.Parameters.Add("@TimeStart",
MySqlDbType.VarChar,8,"TimeStart");
DataAdapter_Slots.UpdateCommand.Parameters.Add("@TimeEnd",
MySqlDbType.VarChar,8,"TimeEnd");
DataAdapter_Slots.UpdateCommand.Parameters.Add("@Pool",
MySqlDbType.VarChar,1,"Pool");
DataAdapter_Slots.UpdateCommand.Parameters.Add("@Workers_Needed",
MySqlDbType.Short,2,"Workers_Needed");
DataAdapter_Slots.UpdateCommand.Parameters.Add("@Workers_Enlisted",
MySqlDbType.Short,2,"Workers_Enlisted");