I
iKiLL
Hi all
The Code is below but i will give you a brief over view first.
I am using C#, SQL Mobile and the CF2.0 with Merge Replication. My Primary
Keys are all "uniqueidentifier" types with default value of
(newsequentialid()) .
Problem is I am trying to save the results for a questioner to a Results
table and it does not work.
I have built a windows mobile control that all seems to be working fine when
the questions are completed it raises the event you see below handing out a
Data Table with all the answers in it.
I then open up a blank Data Table in a Data Set and merge the Data from the
Answers Data Table to the Blank Data Table.
This all seems to work fine, i have checked it by viewing the count, After i
have Merged the count is 18 on both tables which is correct.
But it is like when i call the Data Adaptor Update nothing is going into the
database and there is no error.
I have tried both
oDA.Update(oDS.Tables["Answers"]);
And
oDA.Update(oDS);
But still not saving. And as you can see below i have set up a command
builder.
My other concern is that the Primary Key is a Auto Generated
"uniqueidentifier" column. With a default value of (newsequentialid()).
And this column seems to be blank the whole time. Perhaps it only Generates
the GUID when the Data Adaptor is updated?
Any help would be welcome
### CODE ###
private void QA_Audit_QuestionsFinnished(object sender,
QuestionAnswerControl.QuestionsFinnishedEventArgs e)
{
DataTable dtAnswers = (DataTable)e.AnswersDataTable;
SqlCeCommand oCom = null;
SqlCeCommandBuilder oComBuild = null;
DataSet oDS = null;
SqlCeDataAdapter oDA = null;
string sSQL = "SELECT * 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;
oCom = DBConnection.GetLocalConnection().CreateCommand();
oCom.CommandText = sSQL;
oDA = new SqlCeDataAdapter(oCom);
oComBuild = new SqlCeCommandBuilder();
oComBuild.DataAdapter = oDA;
//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.AcceptChanges();
oDA.Update(oDS.Tables["Answers"]);
}
catch (SqlCeException err)
{
GlobalErrorHandler.ErrHandler(err,
"QA_Audit_QuestionsFinnished");
}
finally
{
if (oDA != null) { oDA.Dispose(); }
}
//Close the form when done.
this.Close();
}
### END CODE ####
Thanks,
ink
The Code is below but i will give you a brief over view first.
I am using C#, SQL Mobile and the CF2.0 with Merge Replication. My Primary
Keys are all "uniqueidentifier" types with default value of
(newsequentialid()) .
Problem is I am trying to save the results for a questioner to a Results
table and it does not work.
I have built a windows mobile control that all seems to be working fine when
the questions are completed it raises the event you see below handing out a
Data Table with all the answers in it.
I then open up a blank Data Table in a Data Set and merge the Data from the
Answers Data Table to the Blank Data Table.
This all seems to work fine, i have checked it by viewing the count, After i
have Merged the count is 18 on both tables which is correct.
But it is like when i call the Data Adaptor Update nothing is going into the
database and there is no error.
I have tried both
oDA.Update(oDS.Tables["Answers"]);
And
oDA.Update(oDS);
But still not saving. And as you can see below i have set up a command
builder.
My other concern is that the Primary Key is a Auto Generated
"uniqueidentifier" column. With a default value of (newsequentialid()).
And this column seems to be blank the whole time. Perhaps it only Generates
the GUID when the Data Adaptor is updated?
Any help would be welcome
### CODE ###
private void QA_Audit_QuestionsFinnished(object sender,
QuestionAnswerControl.QuestionsFinnishedEventArgs e)
{
DataTable dtAnswers = (DataTable)e.AnswersDataTable;
SqlCeCommand oCom = null;
SqlCeCommandBuilder oComBuild = null;
DataSet oDS = null;
SqlCeDataAdapter oDA = null;
string sSQL = "SELECT * 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;
oCom = DBConnection.GetLocalConnection().CreateCommand();
oCom.CommandText = sSQL;
oDA = new SqlCeDataAdapter(oCom);
oComBuild = new SqlCeCommandBuilder();
oComBuild.DataAdapter = oDA;
//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.AcceptChanges();
oDA.Update(oDS.Tables["Answers"]);
}
catch (SqlCeException err)
{
GlobalErrorHandler.ErrHandler(err,
"QA_Audit_QuestionsFinnished");
}
finally
{
if (oDA != null) { oDA.Dispose(); }
}
//Close the form when done.
this.Close();
}
### END CODE ####
Thanks,
ink