I have successfully connected to an Oracle Database, Filled a Dataset w/ data from an Oracle table, and binded a Datagrid to the dataset. Now I want to Open a connection to an Access Database and use a seperate Data Adapter to Update the Datasets records back to the Access Database.There will be no changes to the data in the dataset. I am just using the application to pull data out of an Oracle table and putting it into an Access Table. I have successfully connected to the Access Database after I have filled the Dataset from the Oracle datasource, but I have no clue on how to write the SQL Insert statement. How do you reference what is in the dataset as far as column names. Do the dataset column names match the Oracle column names from the original select statement ? I have successfully completed Insert Statements in past projects when I have worked w/ in one connection and one database. However, with these two separate connections, two different DataSources, it's been quite painful. The btnLoad Event Handler below works great because my DataGrid loads. It's the btnInsert Event Handler which is always hitting the catch. Again filling the dataset is working so please bypass the union query, its pretty difficult to understand, but works well. I have spent about 4 hours looking through 100's of threads here but have not found a solid explanation of how to use a dataset as a temporary holding place between to completely different datasources. Anyone have an answer
private void btnLoad_Click(object sender, System.EventArgs e)
{
string strLoadSQL = "Select SC.INCIDENTSM1.OPENED_BY, Count(*) AS CLOSED, 0 AS OPENED FROM SC.INCIDENTSM1 Where (SC.INCIDENTSM1.CLOSE_TIME
= SC.INCIDENTSM1.OPEN_TIME) AND (SC.INCIDENTSM1.CLOSED_BY = SC.INCIDENTSM1.OPENED_BY) AND (SC.INCIDENTSM1.Entry_Poin
t = 11) AND ((SC.INCIDENTSM1.OPEN_TIME
>= (SYSDATE) - 1)) AND (SC.INCIDENTSM1.OPEN_TIME < (sysdate)) GROUP BY SC.INCIDENTSM1.OPENED_BY,0
UNION Select SC.INCIDENTSM1.OPENED_BY,0
AS CLOSED, Count(*) AS OPENED FROM SC.INCIDENTSM1 Where (SC.INCIDENTSM1.Entry_Poin
t = 11) AND ((SC.INCIDENTSM1.OPEN_TIME
>= (SYSDATE) - 1)) AND (SC.INCIDENTSM1.OPEN_TIME < (sysdate)) GROUP BY SC.INCIDENTSM1.OPENED_BY,0
";
OracleCommand loadCommand = new OracleCommand(strLoadSQL, OracleConn);
OracleDataAdapter loadAdapter = new OracleDataAdapter(loadComm
and);
try
{
OracleConn.Open();
loadAdapter.Fill(my_tempda
taset01, "SC.INCIDENTSM1");
this.dataGrid1.DataSource = my_tempdataset01.Tables[0]
;
}
catch
{
MessageBox.Show("Datagrid Bind Failed");
}
finally
{
OracleConn.Close();
}
}
private void btnInsert_Click(object sender, System.EventArgs e)
{
string strInsertSQL ="INSERT INTO tblProduction_Temp(Peregri
neName, CLOSED, OPENED) VALUES(OPENED_BY, CLOSED, OPENED)";
OleDbCommand InsertCommand = new OleDbCommand(strInsertSQL,
AccessConn);
InsertCommand.CommandType = CommandType.Text;
OleDbDataAdapter InsertAdapter = new OleDbDataAdapter(InsertCom
mand);
try
{
AccessConn.Open();
MessageBox.Show("Access Connection Successfull");
}
catch
{
MessageBox.Show("Access Connection Failed");
}
try
{
InsertAdapter.AcceptChange
sDuringFil
l = false;
InsertAdapter.Update(my_te
mpdataset0
1,"tblProd
uction_Tem
p");
}
catch
{
MessageBox.Show("Insert Failed");
}
finally
{
AccessConn.Close();
}
}