James wrote:
I'm stuck. I have created a console application that does its job of
collecting the data I want it to however I am stuck on writing this data back
to a database. All of the examples I have been able to find on using the
SQLConnectin, SQLDataAdapter and DataSet objects all point me to a forms
application where you can visually modify the data the send the
update,insert,d elete commands. I have not been able to locate how to update
or insert data on a DataSet that is not bound to a visual object of some kind.
Thanks for any assistance...
I think this is what your after. Below is a code snippet that updates
two databases, one via ODBC and another via OLE. Hope this helps.
oleDbConnection 1 = new System.Data.Ole Db.OleDbConnect ion();
odbcConnection1 = new System.Data.Odb c.OdbcConnectio n();
oleDbConnection 1.ConnectionStr ing = @"Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet
OLEDB:Database Password=;Data Source=""C:\Doc uments and Settings\All
Users\Documents \DATA.mdb"";Pas sword=;Jet OLEDB:Engine Type=5;Jet
OLEDB:Global Bulk
Transactions=1; Provider=""Micr osoft.Jet.OLEDB .4.0"";Jet OLEDB:System
database=;Jet OLEDB:SFP=False ;Extended Properties=;Mod e=Share Deny
None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System
Database=False; Jet OLEDB:Don't Copy Locale on Compact=False;J et
OLEDB:Compact Without Replica Repair=False;Us er ID=Admin;Jet
OLEDB:Encrypt Database=False" ;
odbcConnection1 .ConnectionStri ng =
"STMT=;OPTION=5 24292;DSN=Looe; UID=XXXX;PASSWO RD=XXXX;SOCKET= ;DESC=;DATABASE =YYYY;SERV"
+ "ER=192.168.0.7 ;PORT=3306";
oleDbConnection 1.Open();
odbcConnection1 .Open();
OleDbCommand odc = oleDbConnection 1.CreateCommand ();
odc.CommandText = "UPDATE........ .";
odc.ExecuteNonQ uery();
OdbcCommand oc = odbcConnection1 .CreateCommand( );
oc.CommandText = "UPDATE........ ....";
oc.ExecuteNonQu ery();
oc.Close();
odc.Close();
Cheers
Jimbo