473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SqlCeDataAdapter not running Insert Command...

Hi all

I am having problems getting my SqlCeDataAdapter 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.AnswersDataTable;
SqlCeCommand oComSelect = null;
SqlCeCommand oComInsert = null;
//SqlCeCommandBuilder oComBuild = null;
DataSet oDS = null;
SqlCeDataAdapter oDA = null;
//string sSQL = "SELECT [pda_AuRe_AuditResultsID] FROM
AuditResults WHERE 1=2";
string sSQL = "SELECT [AuRe_CreatedDate] ,[AuRe_UpdatedDate]
,[AuRe_TimeStamp] ,[pda_AuRe_AuditsID]";
sSQL += " ,[aure_ResultText] ,[aure_ResultValue]
,[aure_AuditHeaderResult] ,[aure_Floor] ,[aure_RoomName] ";
sSQL += " ,[aure_Comment] ,[pda_aure_RoomTypeId]
,[pda_aure_SurveyQuestionsID]";
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.Globalization.CultureInfo.CurrentCulture;

oComSelect = new SqlCeCommand();
oComSelect.Connection = DBConnection.GetLocalConnection();
oComSelect.CommandText = sSQL;

oDA = new SqlCeDataAdapter(oComSelect);
//oDA.SelectCommand = oCom;
sSQL = "INSERT INTO [AuditResults] ([AuRe_CreatedDate],
[AuRe_UpdatedDate], [AuRe_TimeStamp], [pda_AuRe_AuditsID], ";
sSQL += " [aure_ResultText], [aure_ResultValue],
[aure_AuditHeaderResult], [aure_Floor], [aure_RoomName], ";
sSQL += " [aure_Comment], [pda_aure_RoomTypeId],
[pda_aure_SurveyQuestionsID])";
sSQL += " VALUES (?, ?, ?,? ,?, ?,?,?, ?,?, ?,?)";
//sSQL += " VALUES (@AuRe_CreatedDate, @AuRe_UpdatedDate,
@AuRe_TimeStamp,@pda_AuRe_AuditsID,@aure_ResultTex t,
@aure_ResultValue,@aure_AuditHeaderResult,@aure_Fl oor,
@aure_RoomName,@aure_Comment,
@pda_aure_RoomTypeId,@pda_aure_SurveyQuestionsID)" ;
oComInsert = new SqlCeCommand();
oComInsert.Connection = DBConnection.GetLocalConnection();
oComInsert.CommandText = sSQL;
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_CreatedDate", SqlDbType.DateTime, 8,
"AuRe_CreatedDate"));
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_UpdatedDate", SqlDbType.DateTime, 8,
"AuRe_UpdatedDate"));
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_TimeStamp", SqlDbType.DateTime, 8, "AuRe_TimeStamp"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_AuRe_AuditsID", SqlDbType.UniqueIdentifier, 16,
"pda_AuRe_AuditsID"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_ResultText", SqlDbType.NVarChar, 500,
"aure_ResultText"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_ResultValue", SqlDbType.Int, 4, "aure_ResultValue"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_AuditHeaderResult", SqlDbType.NChar, 1,
"aure_AuditHeaderResult"));
oComInsert.Parameters.Add(new SqlCeParameter("@aure_Floor",
SqlDbType.NVarChar, 50, "aure_Floor"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_RoomName", SqlDbType.NVarChar, 50, "aure_RoomName"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_Comment", SqlDbType.NVarChar, 2000, "aure_Comment"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_aure_RoomTypeId", SqlDbType.UniqueIdentifier, 16,
"pda_aure_RoomTypeId"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_aure_SurveyQuestionsID", SqlDbType.UniqueIdentifier,
16, "pda_aure_SurveyQuestionsID"));
//oComBuild = new SqlCeCommandBuilder(oDA);
//oComBuild.QuotePrefix = "[";
//oComBuild.QuoteSuffix = "]";
//oComBuild.SetAllValues = true;
//oComBuild.DataAdapter = oDA;

//oComInsert = new SqlCeCommand();
//oComInsert =
DBConnection.GetLocalConnection().CreateCommand();
//oComInsert.Parameters.Add(oComBuild.GetInsertComma nd().Parameters);
//oComInsert.CommandText =
oComBuild.GetInsertCommand().CommandText;
//oDA.InsertCommand = oComInsert;
//oDA.InsertCommand.CommandText =
oComBuild.GetInsertCommand().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(dtAnswers);
//oDS.Tables["Answers"].EndLoadData();
oDS.Tables.Add(dtAnswers.Copy());

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

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


Mar 16 '07 #1
3 4679
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***@NotMyEmail.comwrote in message
news:eb****************@TK2MSFTNGP03.phx.gbl...
Hi all

I am having problems getting my SqlCeDataAdapter 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.AnswersDataTable;
SqlCeCommand oComSelect = null;
SqlCeCommand oComInsert = null;
//SqlCeCommandBuilder oComBuild = null;
DataSet oDS = null;
SqlCeDataAdapter oDA = null;
//string sSQL = "SELECT [pda_AuRe_AuditResultsID] FROM
AuditResults WHERE 1=2";
string sSQL = "SELECT [AuRe_CreatedDate] ,[AuRe_UpdatedDate]
,[AuRe_TimeStamp] ,[pda_AuRe_AuditsID]";
sSQL += " ,[aure_ResultText] ,[aure_ResultValue]
,[aure_AuditHeaderResult] ,[aure_Floor] ,[aure_RoomName] ";
sSQL += " ,[aure_Comment] ,[pda_aure_RoomTypeId]
,[pda_aure_SurveyQuestionsID]";
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.Globalization.CultureInfo.CurrentCulture;

oComSelect = new SqlCeCommand();
oComSelect.Connection = DBConnection.GetLocalConnection();
oComSelect.CommandText = sSQL;

oDA = new SqlCeDataAdapter(oComSelect);
//oDA.SelectCommand = oCom;
sSQL = "INSERT INTO [AuditResults] ([AuRe_CreatedDate],
[AuRe_UpdatedDate], [AuRe_TimeStamp], [pda_AuRe_AuditsID], ";
sSQL += " [aure_ResultText], [aure_ResultValue],
[aure_AuditHeaderResult], [aure_Floor], [aure_RoomName], ";
sSQL += " [aure_Comment], [pda_aure_RoomTypeId],
[pda_aure_SurveyQuestionsID])";
sSQL += " VALUES (?, ?, ?,? ,?, ?,?,?, ?,?, ?,?)";
//sSQL += " VALUES (@AuRe_CreatedDate, @AuRe_UpdatedDate,
@AuRe_TimeStamp,@pda_AuRe_AuditsID,@aure_ResultTex t,
@aure_ResultValue,@aure_AuditHeaderResult,@aure_Fl oor,
@aure_RoomName,@aure_Comment,
@pda_aure_RoomTypeId,@pda_aure_SurveyQuestionsID)" ;
oComInsert = new SqlCeCommand();
oComInsert.Connection = DBConnection.GetLocalConnection();
oComInsert.CommandText = sSQL;
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_CreatedDate", SqlDbType.DateTime, 8,
"AuRe_CreatedDate"));
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_UpdatedDate", SqlDbType.DateTime, 8,
"AuRe_UpdatedDate"));
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_TimeStamp", SqlDbType.DateTime, 8,
"AuRe_TimeStamp"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_AuRe_AuditsID", SqlDbType.UniqueIdentifier, 16,
"pda_AuRe_AuditsID"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_ResultText", SqlDbType.NVarChar, 500,
"aure_ResultText"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_ResultValue", SqlDbType.Int, 4,
"aure_ResultValue"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_AuditHeaderResult", SqlDbType.NChar, 1,
"aure_AuditHeaderResult"));
oComInsert.Parameters.Add(new SqlCeParameter("@aure_Floor",
SqlDbType.NVarChar, 50, "aure_Floor"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_RoomName", SqlDbType.NVarChar, 50,
"aure_RoomName"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_Comment", SqlDbType.NVarChar, 2000,
"aure_Comment"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_aure_RoomTypeId", SqlDbType.UniqueIdentifier, 16,
"pda_aure_RoomTypeId"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_aure_SurveyQuestionsID", SqlDbType.UniqueIdentifier,
16, "pda_aure_SurveyQuestionsID"));
//oComBuild = new SqlCeCommandBuilder(oDA);
//oComBuild.QuotePrefix = "[";
//oComBuild.QuoteSuffix = "]";
//oComBuild.SetAllValues = true;
//oComBuild.DataAdapter = oDA;

//oComInsert = new SqlCeCommand();
//oComInsert =
DBConnection.GetLocalConnection().CreateCommand();

//oComInsert.Parameters.Add(oComBuild.GetInsertComma nd().Parameters);
//oComInsert.CommandText =
oComBuild.GetInsertCommand().CommandText;
//oDA.InsertCommand = oComInsert;
//oDA.InsertCommand.CommandText =
oComBuild.GetInsertCommand().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(dtAnswers);
//oDS.Tables["Answers"].EndLoadData();
oDS.Tables.Add(dtAnswers.Copy());

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

}
catch (SqlCeException err)
{
GlobalErrorHandler.ErrHandler(err,
"QA_Audit_QuestionsFinnished");
}
catch (Exception err)
{
GlobalErrorHandler.ErrHandler(err,
"QA_Audit_QuestionsFinnished");
}
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******@newsgroups.nospamwrote in message
news:%2****************@TK2MSFTNGP04.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***@NotMyEmail.comwrote in message
news:eb****************@TK2MSFTNGP03.phx.gbl...
>Hi all

I am having problems getting my SqlCeDataAdapter 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.AnswersDataTable;
SqlCeCommand oComSelect = null;
SqlCeCommand oComInsert = null;
//SqlCeCommandBuilder oComBuild = null;
DataSet oDS = null;
SqlCeDataAdapter oDA = null;
//string sSQL = "SELECT [pda_AuRe_AuditResultsID] FROM
AuditResults WHERE 1=2";
string sSQL = "SELECT [AuRe_CreatedDate] ,[AuRe_UpdatedDate]
,[AuRe_TimeStamp] ,[pda_AuRe_AuditsID]";
sSQL += " ,[aure_ResultText] ,[aure_ResultValue]
,[aure_AuditHeaderResult] ,[aure_Floor] ,[aure_RoomName] ";
sSQL += " ,[aure_Comment] ,[pda_aure_RoomTypeId]
,[pda_aure_SurveyQuestionsID]";
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.Globalization.CultureInfo.CurrentCulture ;

oComSelect = new SqlCeCommand();
oComSelect.Connection = DBConnection.GetLocalConnection();
oComSelect.CommandText = sSQL;

oDA = new SqlCeDataAdapter(oComSelect);
//oDA.SelectCommand = oCom;
sSQL = "INSERT INTO [AuditResults] ([AuRe_CreatedDate],
[AuRe_UpdatedDate], [AuRe_TimeStamp], [pda_AuRe_AuditsID], ";
sSQL += " [aure_ResultText], [aure_ResultValue],
[aure_AuditHeaderResult], [aure_Floor], [aure_RoomName], ";
sSQL += " [aure_Comment], [pda_aure_RoomTypeId],
[pda_aure_SurveyQuestionsID])";
sSQL += " VALUES (?, ?, ?,? ,?, ?,?,?, ?,?, ?,?)";
//sSQL += " VALUES (@AuRe_CreatedDate, @AuRe_UpdatedDate,
@AuRe_TimeStamp,@pda_AuRe_AuditsID,@aure_ResultTe xt,
@aure_ResultValue,@aure_AuditHeaderResult,@aure_F loor,
@aure_RoomName,@aure_Comment,
@pda_aure_RoomTypeId,@pda_aure_SurveyQuestionsID) ";
oComInsert = new SqlCeCommand();
oComInsert.Connection = DBConnection.GetLocalConnection();
oComInsert.CommandText = sSQL;
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_CreatedDate", SqlDbType.DateTime, 8,
"AuRe_CreatedDate"));
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_UpdatedDate", SqlDbType.DateTime, 8,
"AuRe_UpdatedDate"));
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_TimeStamp", SqlDbType.DateTime, 8,
"AuRe_TimeStamp"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_AuRe_AuditsID", SqlDbType.UniqueIdentifier, 16,
"pda_AuRe_AuditsID"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_ResultText", SqlDbType.NVarChar, 500,
"aure_ResultText"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_ResultValue", SqlDbType.Int, 4,
"aure_ResultValue"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_AuditHeaderResult", SqlDbType.NChar, 1,
"aure_AuditHeaderResult"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_Floor", SqlDbType.NVarChar, 50, "aure_Floor"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_RoomName", SqlDbType.NVarChar, 50,
"aure_RoomName"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_Comment", SqlDbType.NVarChar, 2000,
"aure_Comment"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_aure_RoomTypeId", SqlDbType.UniqueIdentifier, 16,
"pda_aure_RoomTypeId"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_aure_SurveyQuestionsID", SqlDbType.UniqueIdentifier,
16, "pda_aure_SurveyQuestionsID"));
//oComBuild = new SqlCeCommandBuilder(oDA);
//oComBuild.QuotePrefix = "[";
//oComBuild.QuoteSuffix = "]";
//oComBuild.SetAllValues = true;
//oComBuild.DataAdapter = oDA;

//oComInsert = new SqlCeCommand();
//oComInsert =
DBConnection.GetLocalConnection().CreateCommand() ;

//oComInsert.Parameters.Add(oComBuild.GetInsertComma nd().Parameters);
//oComInsert.CommandText =
oComBuild.GetInsertCommand().CommandText;
//oDA.InsertCommand = oComInsert;
//oDA.InsertCommand.CommandText =
oComBuild.GetInsertCommand().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(dtAnswers);
//oDS.Tables["Answers"].EndLoadData();
oDS.Tables.Add(dtAnswers.Copy());

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

}
catch (SqlCeException err)
{
GlobalErrorHandler.ErrHandler(err,
"QA_Audit_QuestionsFinnished");
}
catch (Exception err)
{
GlobalErrorHandler.ErrHandler(err,
"QA_Audit_QuestionsFinnished");
}
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******@newsgroups.nospamwrote in message
news:%2****************@TK2MSFTNGP04.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***@NotMyEmail.comwrote in message
news:eb****************@TK2MSFTNGP03.phx.gbl...
>Hi all

I am having problems getting my SqlCeDataAdapter 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.AnswersDataTable;
SqlCeCommand oComSelect = null;
SqlCeCommand oComInsert = null;
//SqlCeCommandBuilder oComBuild = null;
DataSet oDS = null;
SqlCeDataAdapter oDA = null;
//string sSQL = "SELECT [pda_AuRe_AuditResultsID] FROM
AuditResults WHERE 1=2";
string sSQL = "SELECT [AuRe_CreatedDate] ,[AuRe_UpdatedDate]
,[AuRe_TimeStamp] ,[pda_AuRe_AuditsID]";
sSQL += " ,[aure_ResultText] ,[aure_ResultValue]
,[aure_AuditHeaderResult] ,[aure_Floor] ,[aure_RoomName] ";
sSQL += " ,[aure_Comment] ,[pda_aure_RoomTypeId]
,[pda_aure_SurveyQuestionsID]";
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.Globalization.CultureInfo.CurrentCulture ;

oComSelect = new SqlCeCommand();
oComSelect.Connection = DBConnection.GetLocalConnection();
oComSelect.CommandText = sSQL;

oDA = new SqlCeDataAdapter(oComSelect);
//oDA.SelectCommand = oCom;
sSQL = "INSERT INTO [AuditResults] ([AuRe_CreatedDate],
[AuRe_UpdatedDate], [AuRe_TimeStamp], [pda_AuRe_AuditsID], ";
sSQL += " [aure_ResultText], [aure_ResultValue],
[aure_AuditHeaderResult], [aure_Floor], [aure_RoomName], ";
sSQL += " [aure_Comment], [pda_aure_RoomTypeId],
[pda_aure_SurveyQuestionsID])";
sSQL += " VALUES (?, ?, ?,? ,?, ?,?,?, ?,?, ?,?)";
//sSQL += " VALUES (@AuRe_CreatedDate, @AuRe_UpdatedDate,
@AuRe_TimeStamp,@pda_AuRe_AuditsID,@aure_ResultTe xt,
@aure_ResultValue,@aure_AuditHeaderResult,@aure_F loor,
@aure_RoomName,@aure_Comment,
@pda_aure_RoomTypeId,@pda_aure_SurveyQuestionsID) ";
oComInsert = new SqlCeCommand();
oComInsert.Connection = DBConnection.GetLocalConnection();
oComInsert.CommandText = sSQL;
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_CreatedDate", SqlDbType.DateTime, 8,
"AuRe_CreatedDate"));
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_UpdatedDate", SqlDbType.DateTime, 8,
"AuRe_UpdatedDate"));
oComInsert.Parameters.Add(new
SqlCeParameter("@AuRe_TimeStamp", SqlDbType.DateTime, 8,
"AuRe_TimeStamp"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_AuRe_AuditsID", SqlDbType.UniqueIdentifier, 16,
"pda_AuRe_AuditsID"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_ResultText", SqlDbType.NVarChar, 500,
"aure_ResultText"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_ResultValue", SqlDbType.Int, 4,
"aure_ResultValue"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_AuditHeaderResult", SqlDbType.NChar, 1,
"aure_AuditHeaderResult"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_Floor", SqlDbType.NVarChar, 50, "aure_Floor"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_RoomName", SqlDbType.NVarChar, 50,
"aure_RoomName"));
oComInsert.Parameters.Add(new
SqlCeParameter("@aure_Comment", SqlDbType.NVarChar, 2000,
"aure_Comment"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_aure_RoomTypeId", SqlDbType.UniqueIdentifier, 16,
"pda_aure_RoomTypeId"));
oComInsert.Parameters.Add(new
SqlCeParameter("@pda_aure_SurveyQuestionsID", SqlDbType.UniqueIdentifier,
16, "pda_aure_SurveyQuestionsID"));
//oComBuild = new SqlCeCommandBuilder(oDA);
//oComBuild.QuotePrefix = "[";
//oComBuild.QuoteSuffix = "]";
//oComBuild.SetAllValues = true;
//oComBuild.DataAdapter = oDA;

//oComInsert = new SqlCeCommand();
//oComInsert =
DBConnection.GetLocalConnection().CreateCommand() ;

//oComInsert.Parameters.Add(oComBuild.GetInsertComma nd().Parameters);
//oComInsert.CommandText =
oComBuild.GetInsertCommand().CommandText;
//oDA.InsertCommand = oComInsert;
//oDA.InsertCommand.CommandText =
oComBuild.GetInsertCommand().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(dtAnswers);
//oDS.Tables["Answers"].EndLoadData();
oDS.Tables.Add(dtAnswers.Copy());

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

}
catch (SqlCeException err)
{
GlobalErrorHandler.ErrHandler(err,
"QA_Audit_QuestionsFinnished");
}
catch (Exception err)
{
GlobalErrorHandler.ErrHandler(err,
"QA_Audit_QuestionsFinnished");
}
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
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...
0
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
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:...
22
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...
1
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...
0
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...
11
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...
3
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...
7
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.