473,573 Members | 2,918 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SqlCeDataAdapte r not running Insert Command...

Hi all

I am having problems getting my SqlCeDataAdapte r to Update the SQL Mobile
Data base.
i am using C# CF2.
I have tried this a number of different ways. Starting with the command
builder but eventually i wrote out the entire command my self, and still
nothing.
The only thing that i can think this that because i am trying to add a table
that is created outside the data adaptor and then Merge/Copy the data into
the Adaptor so it can be saved.
If some one could take a look at the code below and let me know if it should
work? Or am I doing something wrong cos I have virtually copied this from
the MSDN site and i am getting no errors.

Sorry but there is allot of commenting out because of testing and trying
different things.
Thanks,
ink

#region OLD CODE
DataTable dtAnswers = (DataTable)e.An swersDataTable;
SqlCeCommand oComSelect = null;
SqlCeCommand oComInsert = null;
//SqlCeCommandBui lder oComBuild = null;
DataSet oDS = null;
SqlCeDataAdapte r oDA = null;
//string sSQL = "SELECT [pda_AuRe_AuditR esultsID] FROM
AuditResults WHERE 1=2";
string sSQL = "SELECT [AuRe_CreatedDat e] ,[AuRe_UpdatedDat e]
,[AuRe_TimeStamp] ,[pda_AuRe_Audits ID]";
sSQL += " ,[aure_ResultText] ,[aure_ResultValu e]
,[aure_AuditHeade rResult] ,[aure_Floor] ,[aure_RoomName] ";
sSQL += " ,[aure_Comment] ,[pda_aure_RoomTy peId]
,[pda_aure_Survey QuestionsID]";
sSQL += " FROM AuditResults WHERE 1=2";

try
{
oDS = new DataSet();

//Set the Locale for the DataSet.
//Use the current culture as the default.
oDS.Locale =
System.Globaliz ation.CultureIn fo.CurrentCultu re;

oComSelect = new SqlCeCommand();
oComSelect.Conn ection = DBConnection.Ge tLocalConnectio n();
oComSelect.Comm andText = sSQL;

oDA = new SqlCeDataAdapte r(oComSelect);
//oDA.SelectComma nd = oCom;
sSQL = "INSERT INTO [AuditResults] ([AuRe_CreatedDat e],
[AuRe_UpdatedDat e], [AuRe_TimeStamp], [pda_AuRe_Audits ID], ";
sSQL += " [aure_ResultText], [aure_ResultValu e],
[aure_AuditHeade rResult], [aure_Floor], [aure_RoomName], ";
sSQL += " [aure_Comment], [pda_aure_RoomTy peId],
[pda_aure_Survey QuestionsID])";
sSQL += " VALUES (?, ?, ?,? ,?, ?,?,?, ?,?, ?,?)";
//sSQL += " VALUES (@AuRe_CreatedD ate, @AuRe_UpdatedDa te,
@AuRe_TimeStamp ,@pda_AuRe_Audi tsID,@aure_Resu ltText,
@aure_ResultVal ue,@aure_AuditH eaderResult,@au re_Floor,
@aure_RoomName, @aure_Comment,
@pda_aure_RoomT ypeId,@pda_aure _SurveyQuestion sID)";
oComInsert = new SqlCeCommand();
oComInsert.Conn ection = DBConnection.Ge tLocalConnectio n();
oComInsert.Comm andText = sSQL;
oComInsert.Para meters.Add(new
SqlCeParameter( "@AuRe_CreatedD ate", SqlDbType.DateT ime, 8,
"AuRe_CreatedDa te"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@AuRe_UpdatedD ate", SqlDbType.DateT ime, 8,
"AuRe_UpdatedDa te"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@AuRe_TimeStam p", SqlDbType.DateT ime, 8, "AuRe_TimeStamp "));
oComInsert.Para meters.Add(new
SqlCeParameter( "@pda_AuRe_Audi tsID", SqlDbType.Uniqu eIdentifier, 16,
"pda_AuRe_Audit sID"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@aure_ResultTe xt", SqlDbType.NVarC har, 500,
"aure_ResultTex t"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@aure_ResultVa lue", SqlDbType.Int, 4, "aure_ResultVal ue"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@aure_AuditHea derResult", SqlDbType.NChar , 1,
"aure_AuditHead erResult"));
oComInsert.Para meters.Add(new SqlCeParameter( "@aure_Floo r",
SqlDbType.NVarC har, 50, "aure_Floor "));
oComInsert.Para meters.Add(new
SqlCeParameter( "@aure_RoomName ", SqlDbType.NVarC har, 50, "aure_RoomName" ));
oComInsert.Para meters.Add(new
SqlCeParameter( "@aure_Comment" , SqlDbType.NVarC har, 2000, "aure_Comment") );
oComInsert.Para meters.Add(new
SqlCeParameter( "@pda_aure_Room TypeId", SqlDbType.Uniqu eIdentifier, 16,
"pda_aure_RoomT ypeId"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@pda_aure_Surv eyQuestionsID", SqlDbType.Uniqu eIdentifier,
16, "pda_aure_Surve yQuestionsID")) ;
//oComBuild = new SqlCeCommandBui lder(oDA);
//oComBuild.Quote Prefix = "[";
//oComBuild.Quote Suffix = "]";
//oComBuild.SetAl lValues = true;
//oComBuild.DataA dapter = oDA;

//oComInsert = new SqlCeCommand();
//oComInsert =
DBConnection.Ge tLocalConnectio n().CreateComma nd();
//oComInsert.Para meters.Add(oCom Build.GetInsert Command().Param eters);
//oComInsert.Comm andText =
oComBuild.GetIn sertCommand().C ommandText;
//oDA.InsertComma nd = oComInsert;
//oDA.InsertComma nd.CommandText =
oComBuild.GetIn sertCommand().C ommandText;

////Use the Combo Name for the data table name to.
//if (oDS.Tables["Answers"] == null)
//{
// //Fill the DataTable People within the DataSet sqlDS
// oDA.Fill(oDS, "Answers");
//}
//else
//{
// // Refresh the Employees DataSet.
// oDS.Clear();
// oDA.Fill(oDS, "Answers");
//}

//oDS.Tables["Answers"].BeginLoadData( );
//oDS.Tables["Answers"].Merge(dtAnswer s);
//oDS.Tables["Answers"].EndLoadData();
oDS.Tables.Add( dtAnswers.Copy( ));

//oDA.Update(oDS. Tables["Answers"]);
oDA.Update(oDS, "Answers");
oDS.AcceptChang es();

}
catch (SqlCeException err)
{
GlobalErrorHand ler.ErrHandler( err,
"QA_Audit_Quest ionsFinnished") ;
}
catch (Exception err)
{
GlobalErrorHand ler.ErrHandler( err,
"QA_Audit_Quest ionsFinnished") ;
}
finally
{
if (oDA != null) { oDA.Dispose(); }
}
//Close the form when done.
this.Close();
#endregion


Mar 16 '07 #1
3 4696
I would get lost reading thru all of those strings, so I'm going to just try
to touch the basics ...

One thing to keep in mind: A data adapter does not "save" or "hold"
anything. Think of it as a bridge between your in-memory data (datatables or
datasets) and the actual database.

Command builders are worse than worthless. I don't even want to go there.

If you are not updating your database, then you most likely have a problem
with the Update SQL, the command object or parameters therein.

I saw an Insert command in your code, but I did not see an Update command.
Insert adds new data, Update changes it.

To test your problem fairly easily, you might set up a test app for Winforms
and see if you can update a sample database (NOT on the Mobile device). Find
your problems there (much easier to debug), then go back to the Mobile code
and resolve it.

"iKiLL" <iK***@NotMyEma il.comwrote in message
news:eb******** ********@TK2MSF TNGP03.phx.gbl. ..
Hi all

I am having problems getting my SqlCeDataAdapte r to Update the SQL Mobile
Data base.
i am using C# CF2.
I have tried this a number of different ways. Starting with the command
builder but eventually i wrote out the entire command my self, and still
nothing.
The only thing that i can think this that because i am trying to add a
table that is created outside the data adaptor and then Merge/Copy the
data into the Adaptor so it can be saved.
If some one could take a look at the code below and let me know if it
should work? Or am I doing something wrong cos I have virtually copied
this from the MSDN site and i am getting no errors.

Sorry but there is allot of commenting out because of testing and trying
different things.
Thanks,
ink

#region OLD CODE
DataTable dtAnswers = (DataTable)e.An swersDataTable;
SqlCeCommand oComSelect = null;
SqlCeCommand oComInsert = null;
//SqlCeCommandBui lder oComBuild = null;
DataSet oDS = null;
SqlCeDataAdapte r oDA = null;
//string sSQL = "SELECT [pda_AuRe_AuditR esultsID] FROM
AuditResults WHERE 1=2";
string sSQL = "SELECT [AuRe_CreatedDat e] ,[AuRe_UpdatedDat e]
,[AuRe_TimeStamp] ,[pda_AuRe_Audits ID]";
sSQL += " ,[aure_ResultText] ,[aure_ResultValu e]
,[aure_AuditHeade rResult] ,[aure_Floor] ,[aure_RoomName] ";
sSQL += " ,[aure_Comment] ,[pda_aure_RoomTy peId]
,[pda_aure_Survey QuestionsID]";
sSQL += " FROM AuditResults WHERE 1=2";

try
{
oDS = new DataSet();

//Set the Locale for the DataSet.
//Use the current culture as the default.
oDS.Locale =
System.Globaliz ation.CultureIn fo.CurrentCultu re;

oComSelect = new SqlCeCommand();
oComSelect.Conn ection = DBConnection.Ge tLocalConnectio n();
oComSelect.Comm andText = sSQL;

oDA = new SqlCeDataAdapte r(oComSelect);
//oDA.SelectComma nd = oCom;
sSQL = "INSERT INTO [AuditResults] ([AuRe_CreatedDat e],
[AuRe_UpdatedDat e], [AuRe_TimeStamp], [pda_AuRe_Audits ID], ";
sSQL += " [aure_ResultText], [aure_ResultValu e],
[aure_AuditHeade rResult], [aure_Floor], [aure_RoomName], ";
sSQL += " [aure_Comment], [pda_aure_RoomTy peId],
[pda_aure_Survey QuestionsID])";
sSQL += " VALUES (?, ?, ?,? ,?, ?,?,?, ?,?, ?,?)";
//sSQL += " VALUES (@AuRe_CreatedD ate, @AuRe_UpdatedDa te,
@AuRe_TimeStamp ,@pda_AuRe_Audi tsID,@aure_Resu ltText,
@aure_ResultVal ue,@aure_AuditH eaderResult,@au re_Floor,
@aure_RoomName, @aure_Comment,
@pda_aure_RoomT ypeId,@pda_aure _SurveyQuestion sID)";
oComInsert = new SqlCeCommand();
oComInsert.Conn ection = DBConnection.Ge tLocalConnectio n();
oComInsert.Comm andText = sSQL;
oComInsert.Para meters.Add(new
SqlCeParameter( "@AuRe_CreatedD ate", SqlDbType.DateT ime, 8,
"AuRe_CreatedDa te"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@AuRe_UpdatedD ate", SqlDbType.DateT ime, 8,
"AuRe_UpdatedDa te"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@AuRe_TimeStam p", SqlDbType.DateT ime, 8,
"AuRe_TimeStamp "));
oComInsert.Para meters.Add(new
SqlCeParameter( "@pda_AuRe_Audi tsID", SqlDbType.Uniqu eIdentifier, 16,
"pda_AuRe_Audit sID"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@aure_ResultTe xt", SqlDbType.NVarC har, 500,
"aure_ResultTex t"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@aure_ResultVa lue", SqlDbType.Int, 4,
"aure_ResultVal ue"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@aure_AuditHea derResult", SqlDbType.NChar , 1,
"aure_AuditHead erResult"));
oComInsert.Para meters.Add(new SqlCeParameter( "@aure_Floo r",
SqlDbType.NVarC har, 50, "aure_Floor "));
oComInsert.Para meters.Add(new
SqlCeParameter( "@aure_RoomName ", SqlDbType.NVarC har, 50,
"aure_RoomName" ));
oComInsert.Para meters.Add(new
SqlCeParameter( "@aure_Comment" , SqlDbType.NVarC har, 2000,
"aure_Comment") );
oComInsert.Para meters.Add(new
SqlCeParameter( "@pda_aure_Room TypeId", SqlDbType.Uniqu eIdentifier, 16,
"pda_aure_RoomT ypeId"));
oComInsert.Para meters.Add(new
SqlCeParameter( "@pda_aure_Surv eyQuestionsID", SqlDbType.Uniqu eIdentifier,
16, "pda_aure_Surve yQuestionsID")) ;
//oComBuild = new SqlCeCommandBui lder(oDA);
//oComBuild.Quote Prefix = "[";
//oComBuild.Quote Suffix = "]";
//oComBuild.SetAl lValues = true;
//oComBuild.DataA dapter = oDA;

//oComInsert = new SqlCeCommand();
//oComInsert =
DBConnection.Ge tLocalConnectio n().CreateComma nd();

//oComInsert.Para meters.Add(oCom Build.GetInsert Command().Param eters);
//oComInsert.Comm andText =
oComBuild.GetIn sertCommand().C ommandText;
//oDA.InsertComma nd = oComInsert;
//oDA.InsertComma nd.CommandText =
oComBuild.GetIn sertCommand().C ommandText;

////Use the Combo Name for the data table name to.
//if (oDS.Tables["Answers"] == null)
//{
// //Fill the DataTable People within the DataSet sqlDS
// oDA.Fill(oDS, "Answers");
//}
//else
//{
// // Refresh the Employees DataSet.
// oDS.Clear();
// oDA.Fill(oDS, "Answers");
//}

//oDS.Tables["Answers"].BeginLoadData( );
//oDS.Tables["Answers"].Merge(dtAnswer s);
//oDS.Tables["Answers"].EndLoadData();
oDS.Tables.Add( dtAnswers.Copy( ));

//oDA.Update(oDS. Tables["Answers"]);
oDA.Update(oDS, "Answers");
oDS.AcceptChang es();

}
catch (SqlCeException err)
{
GlobalErrorHand ler.ErrHandler( err,
"QA_Audit_Quest ionsFinnished") ;
}
catch (Exception err)
{
GlobalErrorHand ler.ErrHandler( err,
"QA_Audit_Quest ionsFinnished") ;
}
finally
{
if (oDA != null) { oDA.Dispose(); }
}
//Close the form when done.
this.Close();
#endregion


Mar 18 '07 #2
Thanks for the Advice Earl.


"Earl" <br******@newsg roups.nospamwro te in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>I would get lost reading thru all of those strings, so I'm going to just
try to touch the basics ...

One thing to keep in mind: A data adapter does not "save" or "hold"
anything. Think of it as a bridge between your in-memory data (datatables
or datasets) and the actual database.

Command builders are worse than worthless. I don't even want to go there.

If you are not updating your database, then you most likely have a problem
with the Update SQL, the command object or parameters therein.

I saw an Insert command in your code, but I did not see an Update command.
Insert adds new data, Update changes it.

To test your problem fairly easily, you might set up a test app for
Winforms and see if you can update a sample database (NOT on the Mobile
device). Find your problems there (much easier to debug), then go back to
the Mobile code and resolve it.

"iKiLL" <iK***@NotMyEma il.comwrote in message
news:eb******** ********@TK2MSF TNGP03.phx.gbl. ..
>Hi all

I am having problems getting my SqlCeDataAdapte r to Update the SQL Mobile
Data base.
i am using C# CF2.
I have tried this a number of different ways. Starting with the command
builder but eventually i wrote out the entire command my self, and still
nothing.
The only thing that i can think this that because i am trying to add a
table that is created outside the data adaptor and then Merge/Copy the
data into the Adaptor so it can be saved.
If some one could take a look at the code below and let me know if it
should work? Or am I doing something wrong cos I have virtually copied
this from the MSDN site and i am getting no errors.

Sorry but there is allot of commenting out because of testing and trying
different things.
Thanks,
ink

#region OLD CODE
DataTable dtAnswers = (DataTable)e.An swersDataTable;
SqlCeCommand oComSelect = null;
SqlCeCommand oComInsert = null;
//SqlCeCommandBui lder oComBuild = null;
DataSet oDS = null;
SqlCeDataAdapte r oDA = null;
//string sSQL = "SELECT [pda_AuRe_AuditR esultsID] FROM
AuditResults WHERE 1=2";
string sSQL = "SELECT [AuRe_CreatedDat e] ,[AuRe_UpdatedDat e]
,[AuRe_TimeStamp] ,[pda_AuRe_Audits ID]";
sSQL += " ,[aure_ResultText] ,[aure_ResultValu e]
,[aure_AuditHeade rResult] ,[aure_Floor] ,[aure_RoomName] ";
sSQL += " ,[aure_Comment] ,[pda_aure_RoomTy peId]
,[pda_aure_Survey QuestionsID]";
sSQL += " FROM AuditResults WHERE 1=2";

try
{
oDS = new DataSet();

//Set the Locale for the DataSet.
//Use the current culture as the default.
oDS.Locale =
System.Globali zation.CultureI nfo.CurrentCult ure;

oComSelect = new SqlCeCommand();
oComSelect.Conn ection = DBConnection.Ge tLocalConnectio n();
oComSelect.Comm andText = sSQL;

oDA = new SqlCeDataAdapte r(oComSelect);
//oDA.SelectComma nd = oCom;
sSQL = "INSERT INTO [AuditResults] ([AuRe_CreatedDat e],
[AuRe_UpdatedDat e], [AuRe_TimeStamp], [pda_AuRe_Audits ID], ";
sSQL += " [aure_ResultText], [aure_ResultValu e],
[aure_AuditHeade rResult], [aure_Floor], [aure_RoomName], ";
sSQL += " [aure_Comment], [pda_aure_RoomTy peId],
[pda_aure_Survey QuestionsID])";
sSQL += " VALUES (?, ?, ?,? ,?, ?,?,?, ?,?, ?,?)";
//sSQL += " VALUES (@AuRe_CreatedD ate, @AuRe_UpdatedDa te,
@AuRe_TimeStam p,@pda_AuRe_Aud itsID,@aure_Res ultText,
@aure_ResultVa lue,@aure_Audit HeaderResult,@a ure_Floor,
@aure_RoomName ,@aure_Comment,
@pda_aure_Room TypeId,@pda_aur e_SurveyQuestio nsID)";
oComInsert = new SqlCeCommand();
oComInsert.Conn ection = DBConnection.Ge tLocalConnectio n();
oComInsert.Comm andText = sSQL;
oComInsert.Para meters.Add(new
SqlCeParameter ("@AuRe_Created Date", SqlDbType.DateT ime, 8,
"AuRe_CreatedD ate"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@AuRe_Updated Date", SqlDbType.DateT ime, 8,
"AuRe_UpdatedD ate"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@AuRe_TimeSta mp", SqlDbType.DateT ime, 8,
"AuRe_TimeStam p"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@pda_AuRe_Aud itsID", SqlDbType.Uniqu eIdentifier, 16,
"pda_AuRe_Audi tsID"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_ResultT ext", SqlDbType.NVarC har, 500,
"aure_ResultTe xt"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_ResultV alue", SqlDbType.Int, 4,
"aure_ResultVa lue"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_AuditHe aderResult", SqlDbType.NChar , 1,
"aure_AuditHea derResult"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_Floo r", SqlDbType.NVarC har, 50, "aure_Floor "));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_RoomNam e", SqlDbType.NVarC har, 50,
"aure_RoomName "));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_Comment ", SqlDbType.NVarC har, 2000,
"aure_Comment" ));
oComInsert.Para meters.Add(new
SqlCeParameter ("@pda_aure_Roo mTypeId", SqlDbType.Uniqu eIdentifier, 16,
"pda_aure_Room TypeId"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@pda_aure_Sur veyQuestionsID" , SqlDbType.Uniqu eIdentifier,
16, "pda_aure_Surve yQuestionsID")) ;
//oComBuild = new SqlCeCommandBui lder(oDA);
//oComBuild.Quote Prefix = "[";
//oComBuild.Quote Suffix = "]";
//oComBuild.SetAl lValues = true;
//oComBuild.DataA dapter = oDA;

//oComInsert = new SqlCeCommand();
//oComInsert =
DBConnection.G etLocalConnecti on().CreateComm and();

//oComInsert.Para meters.Add(oCom Build.GetInsert Command().Param eters);
//oComInsert.Comm andText =
oComBuild.GetI nsertCommand(). CommandText;
//oDA.InsertComma nd = oComInsert;
//oDA.InsertComma nd.CommandText =
oComBuild.GetI nsertCommand(). CommandText;

////Use the Combo Name for the data table name to.
//if (oDS.Tables["Answers"] == null)
//{
// //Fill the DataTable People within the DataSet sqlDS
// oDA.Fill(oDS, "Answers");
//}
//else
//{
// // Refresh the Employees DataSet.
// oDS.Clear();
// oDA.Fill(oDS, "Answers");
//}

//oDS.Tables["Answers"].BeginLoadData( );
//oDS.Tables["Answers"].Merge(dtAnswer s);
//oDS.Tables["Answers"].EndLoadData();
oDS.Tables.Add( dtAnswers.Copy( ));

//oDA.Update(oDS. Tables["Answers"]);
oDA.Update(oDS, "Answers");
oDS.AcceptChang es();

}
catch (SqlCeException err)
{
GlobalErrorHand ler.ErrHandler( err,
"QA_Audit_Ques tionsFinnished" );
}
catch (Exception err)
{
GlobalErrorHand ler.ErrHandler( err,
"QA_Audit_Ques tionsFinnished" );
}
finally
{
if (oDA != null) { oDA.Dispose(); }
}
//Close the form when done.
this.Close();
#endregion



Mar 19 '07 #3

I Think the problem with my data addaptor.
I have writen a test like you sugested and it works.
The Primary Key is an GUID with a default value and i have also made it the
ROWGUID.
It seems that when i create the select command and explicetly add the Key
Column it still does not exist in the Action commands and if you want to use
the command builder you have to have the Primary Key Column.

I am not 100 pecent yet but i will test this theory and see.

The strange thing is that when i create each command manualy i still get the
sam problem.

ink

"Earl" <br******@newsg roups.nospamwro te in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>I would get lost reading thru all of those strings, so I'm going to just
try to touch the basics ...

One thing to keep in mind: A data adapter does not "save" or "hold"
anything. Think of it as a bridge between your in-memory data (datatables
or datasets) and the actual database.

Command builders are worse than worthless. I don't even want to go there.

If you are not updating your database, then you most likely have a problem
with the Update SQL, the command object or parameters therein.

I saw an Insert command in your code, but I did not see an Update command.
Insert adds new data, Update changes it.

To test your problem fairly easily, you might set up a test app for
Winforms and see if you can update a sample database (NOT on the Mobile
device). Find your problems there (much easier to debug), then go back to
the Mobile code and resolve it.

"iKiLL" <iK***@NotMyEma il.comwrote in message
news:eb******** ********@TK2MSF TNGP03.phx.gbl. ..
>Hi all

I am having problems getting my SqlCeDataAdapte r to Update the SQL Mobile
Data base.
i am using C# CF2.
I have tried this a number of different ways. Starting with the command
builder but eventually i wrote out the entire command my self, and still
nothing.
The only thing that i can think this that because i am trying to add a
table that is created outside the data adaptor and then Merge/Copy the
data into the Adaptor so it can be saved.
If some one could take a look at the code below and let me know if it
should work? Or am I doing something wrong cos I have virtually copied
this from the MSDN site and i am getting no errors.

Sorry but there is allot of commenting out because of testing and trying
different things.
Thanks,
ink

#region OLD CODE
DataTable dtAnswers = (DataTable)e.An swersDataTable;
SqlCeCommand oComSelect = null;
SqlCeCommand oComInsert = null;
//SqlCeCommandBui lder oComBuild = null;
DataSet oDS = null;
SqlCeDataAdapte r oDA = null;
//string sSQL = "SELECT [pda_AuRe_AuditR esultsID] FROM
AuditResults WHERE 1=2";
string sSQL = "SELECT [AuRe_CreatedDat e] ,[AuRe_UpdatedDat e]
,[AuRe_TimeStamp] ,[pda_AuRe_Audits ID]";
sSQL += " ,[aure_ResultText] ,[aure_ResultValu e]
,[aure_AuditHeade rResult] ,[aure_Floor] ,[aure_RoomName] ";
sSQL += " ,[aure_Comment] ,[pda_aure_RoomTy peId]
,[pda_aure_Survey QuestionsID]";
sSQL += " FROM AuditResults WHERE 1=2";

try
{
oDS = new DataSet();

//Set the Locale for the DataSet.
//Use the current culture as the default.
oDS.Locale =
System.Globali zation.CultureI nfo.CurrentCult ure;

oComSelect = new SqlCeCommand();
oComSelect.Conn ection = DBConnection.Ge tLocalConnectio n();
oComSelect.Comm andText = sSQL;

oDA = new SqlCeDataAdapte r(oComSelect);
//oDA.SelectComma nd = oCom;
sSQL = "INSERT INTO [AuditResults] ([AuRe_CreatedDat e],
[AuRe_UpdatedDat e], [AuRe_TimeStamp], [pda_AuRe_Audits ID], ";
sSQL += " [aure_ResultText], [aure_ResultValu e],
[aure_AuditHeade rResult], [aure_Floor], [aure_RoomName], ";
sSQL += " [aure_Comment], [pda_aure_RoomTy peId],
[pda_aure_Survey QuestionsID])";
sSQL += " VALUES (?, ?, ?,? ,?, ?,?,?, ?,?, ?,?)";
//sSQL += " VALUES (@AuRe_CreatedD ate, @AuRe_UpdatedDa te,
@AuRe_TimeStam p,@pda_AuRe_Aud itsID,@aure_Res ultText,
@aure_ResultVa lue,@aure_Audit HeaderResult,@a ure_Floor,
@aure_RoomName ,@aure_Comment,
@pda_aure_Room TypeId,@pda_aur e_SurveyQuestio nsID)";
oComInsert = new SqlCeCommand();
oComInsert.Conn ection = DBConnection.Ge tLocalConnectio n();
oComInsert.Comm andText = sSQL;
oComInsert.Para meters.Add(new
SqlCeParameter ("@AuRe_Created Date", SqlDbType.DateT ime, 8,
"AuRe_CreatedD ate"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@AuRe_Updated Date", SqlDbType.DateT ime, 8,
"AuRe_UpdatedD ate"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@AuRe_TimeSta mp", SqlDbType.DateT ime, 8,
"AuRe_TimeStam p"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@pda_AuRe_Aud itsID", SqlDbType.Uniqu eIdentifier, 16,
"pda_AuRe_Audi tsID"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_ResultT ext", SqlDbType.NVarC har, 500,
"aure_ResultTe xt"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_ResultV alue", SqlDbType.Int, 4,
"aure_ResultVa lue"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_AuditHe aderResult", SqlDbType.NChar , 1,
"aure_AuditHea derResult"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_Floo r", SqlDbType.NVarC har, 50, "aure_Floor "));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_RoomNam e", SqlDbType.NVarC har, 50,
"aure_RoomName "));
oComInsert.Para meters.Add(new
SqlCeParameter ("@aure_Comment ", SqlDbType.NVarC har, 2000,
"aure_Comment" ));
oComInsert.Para meters.Add(new
SqlCeParameter ("@pda_aure_Roo mTypeId", SqlDbType.Uniqu eIdentifier, 16,
"pda_aure_Room TypeId"));
oComInsert.Para meters.Add(new
SqlCeParameter ("@pda_aure_Sur veyQuestionsID" , SqlDbType.Uniqu eIdentifier,
16, "pda_aure_Surve yQuestionsID")) ;
//oComBuild = new SqlCeCommandBui lder(oDA);
//oComBuild.Quote Prefix = "[";
//oComBuild.Quote Suffix = "]";
//oComBuild.SetAl lValues = true;
//oComBuild.DataA dapter = oDA;

//oComInsert = new SqlCeCommand();
//oComInsert =
DBConnection.G etLocalConnecti on().CreateComm and();

//oComInsert.Para meters.Add(oCom Build.GetInsert Command().Param eters);
//oComInsert.Comm andText =
oComBuild.GetI nsertCommand(). CommandText;
//oDA.InsertComma nd = oComInsert;
//oDA.InsertComma nd.CommandText =
oComBuild.GetI nsertCommand(). CommandText;

////Use the Combo Name for the data table name to.
//if (oDS.Tables["Answers"] == null)
//{
// //Fill the DataTable People within the DataSet sqlDS
// oDA.Fill(oDS, "Answers");
//}
//else
//{
// // Refresh the Employees DataSet.
// oDS.Clear();
// oDA.Fill(oDS, "Answers");
//}

//oDS.Tables["Answers"].BeginLoadData( );
//oDS.Tables["Answers"].Merge(dtAnswer s);
//oDS.Tables["Answers"].EndLoadData();
oDS.Tables.Add( dtAnswers.Copy( ));

//oDA.Update(oDS. Tables["Answers"]);
oDA.Update(oDS, "Answers");
oDS.AcceptChang es();

}
catch (SqlCeException err)
{
GlobalErrorHand ler.ErrHandler( err,
"QA_Audit_Ques tionsFinnished" );
}
catch (Exception err)
{
GlobalErrorHand ler.ErrHandler( err,
"QA_Audit_Ques tionsFinnished" );
}
finally
{
if (oDA != null) { oDA.Dispose(); }
}
//Close the form when done.
this.Close();
#endregion



Mar 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3160
by: Bob Murdoch | last post by:
I'm developing an intranet application using W2k server and IE5.5 - 6.x clients. I've got one particular function that calls a stored procedure to update a number of records, depending on user input. The problem we have run into is that this procedure can take a few minutes to complete in certain circumstances, and of course IIS times out. ...
0
1049
by: David | last post by:
Hello. I have some questions about using SqlCeDataAdapter: How can I create and link SqlCeDataAdapter to some table and generate SQL commannds in Compact Framework?
0
2097
by: Ghost | last post by:
Hello. I have such question: I want to create SqlCeDataAdapter object at runtime... I'm writing: SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(); then I specify Select Command: dataAdapter.SelectCommand = new SqlCeCommand("SELECT * FROM Supplier",
22
4273
by: M K | last post by:
Heres my SP: ( i am trying to add more than 1 field but get the same error no matter how many i try to add, i thought i would try to insert the primary key only and work up from there but the primary key insert didnt work either. I can run the SP manually in Visual Studio .NET and it works. When i try to do this it doesn't. Any help is...
1
5765
by: Ennio-Sr | last post by:
Hi all! Testing a script where I need to make sure that postgresql is running before passing a <psql dbasename -c "insert into ..." > instruction I faced this curious behaviour: This is the relevant content of the script: ------------------ #!/bin/bash /usr/lib/postgresql/bin/pg_ctl status -D /var/lib/postgres/data >/dev/null 2>&1 rtn=$?
0
1029
by: Ivana | last post by:
Hi. I'm having trouble with my PocketPC program. I'm getting an InvalidProgramException when the SqlCeDataAdapter.Fill() method is called, and I have no clue why! Is there anybody who can tell me why this exception is thrown? Info: I'm using Microsoft VS 2005 prof ed, Sql Mobile 2005, .Net CF 2.0, and the pocketpc is running windows...
11
21982
by: Gregor Kovaè | last post by:
Hi! I have an SQL script with bunch of CREATE TABLES, ALTER TABLES, ... I'd like it to run transactially. I have found that id I run a ALTER STATEMENT inside a transaction and then roll it back the changes disapear. So if this works for one statement it should also for a script, right ? I run the script with the following command: db2cmd...
3
2176
by: kbcompany | last post by:
Hi I have just started learning oracle. i have created a table with name imp_master and columns item_code with constraint not null, item_name with constraint n1 not null(n1 is user defined constraint name), item_rate and item_desc. the copmmand is as follows... CODE:
7
3199
by: Matt | last post by:
So as you all know the great thing about ADO.NET is that I can take an entire table from a database and dump it into an in memory datatable using ADO.NET. Well my question is that now that I have this temporary table, is it possible to run SQL commands against it like it were an "actual" table. To give a simplistic example, lets say I...
0
8021
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8202
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6419
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5291
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3732
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3733
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2213
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1303
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1041
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.