473,473 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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

Mar 15 '07 #1
3 1324
Try to write shorter questions, and smobody will actually read it!
And then, if you are lucky, provide you with an answer.
"iKiLL" <iK***@NotMyEmail.comwrote in message
news:ed**************@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

Mar 15 '07 #2
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" <iK***@NotMyEmail.comwrote in message
news:ed**************@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
Mar 15 '07 #3
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" <ne***@nospam.opennetcf.comwrote in message
news:E1**********************************@microsof t.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" <iK***@NotMyEmail.comwrote in message
news:ed**************@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.QuestionsFinnishedEventAr gs 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

Mar 15 '07 #4

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

Similar topics

2
by: Bonj | last post by:
Hi I've been following the example on http://aspnet.4guysfromrolla.com/articles/071002-1.3.aspx and no matter what I do, i can't get the DataGrid1_EditCommand event handler to fire. Could...
2
by: headware | last post by:
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design question regarding the use of web services and APS.NET applications. Right now we have an application that uses web services to...
2
by: marcmc | last post by:
Hey, I have never used a datagrid/dataset/adaptor/table method for updating data, I have always used direct updates to the database so ADO is quite new to me. I have a datagrid and I change a...
7
by: Darhl Thomason | last post by:
Does VB2005 have a wizard for creating a form based on an Access db? I know that VB6 had this, but I can't seem to find anything similar in VB2005. Thanks! Darhl
1
by: shwetagupta | last post by:
Hi I am Trying to insert data in M S Access through ASP, but it is neither showing any error nor updating the database. Please tell me ,where i am making the mistake code: <html> <% set...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
1
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
1
by: Wavey | last post by:
Hi All, I have a problem with updating an Access database from a datatable. I have two rows of data in my database at the moment for testing, the first row is an ID number (primary key), the...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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...
0
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 ...

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.