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

Re: Data Addaptor Not updating database?? Can some on tell me what i am missing please. by TheMaxx

TheMaxx
Thu Mar 15 04:48:51 CDT 2007

Try to write shorter questions, and smobody will actually read it!
And then, if you are lucky, provide you with an answer.


"iKiLL" <iKill@NotMyEmail.com> wrote in message
news:edNNRZuZHHA.1296@TK2MSFTNGP02.phx.gbl...
> 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
>
>
>



Re: Data Addaptor Not updating database?? Can some on tell me what i am missing please. by Neil

Neil
Thu Mar 15 05:05:15 CDT 2007

Your first mistake is in assuming that a uniqueidentifier field in SQL is a
GUID when you set the default to newsequentialid(). Take a look at the table
in SQL and I bet you'll find the uniqueidentifier field is actually an int.

--
Neil Cowburn
Principal Partner
OpenNETCF Consulting, LLC.

Managed Code in the Embedded World

http://www.opennetcf.com/
http://www.smartdeviceframework.com/


"iKiLL" <iKill@NotMyEmail.com> wrote in message
news:edNNRZuZHHA.1296@TK2MSFTNGP02.phx.gbl...
> 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
>
>
>


Re: Data Addaptor Not updating database?? Can some on tell me what i am missing please. by iKiLL

iKiLL
Thu Mar 15 05:18:57 CDT 2007

Hi Neil

It is defiantly a GUID, I have set the RowGUID Property to Yes for
Replication. And if i insert a row at the server this is the result, this
looks like a GUID to me "7e78fe39-ded2-db11-900f-000c291f3152"
Sorry about the spacing on the Question, When i posted the Message it was
not that big. Something has happened to it.
Do you think that perhaps the problem is the Command Builder?

Thanks,
ink




"Neil Cowburn" <neilc@nospam.opennetcf.com> wrote in message
news:E18E301F-7A10-4AF0-B28B-7873AA7459E5@microsoft.com...
> Your first mistake is in assuming that a uniqueidentifier field in SQL is
> a GUID when you set the default to newsequentialid(). Take a look at the
> table in SQL and I bet you'll find the uniqueidentifier field is actually
> an int.
>
> --
> Neil Cowburn
> Principal Partner
> OpenNETCF Consulting, LLC.
>
> Managed Code in the Embedded World
>
> http://www.opennetcf.com/
> http://www.smartdeviceframework.com/
>
>
> "iKiLL" <iKill@NotMyEmail.com> wrote in message
> news:edNNRZuZHHA.1296@TK2MSFTNGP02.phx.gbl...
>> 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
>>
>>
>>
>