ADO.NET 2.0 autoincrement problem using SQL 2005 & Web Services

  • Thread starter Werner Wopienka
  • Start date
W

Werner Wopienka

Hi NG!

I've tried the sample walkthrough: Creating a Distrubited Application with
my database which includes a autoincrement value.

My problem is that i don't get the current autoincrement value from the SQL
Server when the table is empty. I clicked the save button whiches sends the
datatable via WS to the sql server but the id in the datatable is incorrect.

The problem does not occur when i connect the windows app directly to the
sql server.
Is there any way to get the latest autoincrement value from the sql server
to set it correctly into the datatable?

thx 4 any help

Werner
 
M

Miha Markic [MVP C#]

Hi Werner,

Why don't you send over the DataTable.GetChanges() and return the same data
populated with server assigned ids?
How do you retrieve ID?
 
C

Cor Ligthert [MVP]

Werner,

There is one error in that sample. .

The datatable.haschanges does not exist.

You can use instead of that in VBNet Format.

If DataTable.GetChanges IsNot Nothing then

An other problem is that there is no right separation of the VBNet and the
C# samples, you can think that both are a part of those

However I have tried it several times and it should go for the rest.
(I assuming you are now talking about the new format)

http://msdn2.microsoft.com/en-us/library/1as0t7ff.aspx

The old one goes fine

http://msdn.microsoft.com/library/d...atingDistributedWebApplicationWalkthrough.asp

I hope that helps,

Cor
 
W

Werner Wopienka

Hi Miha!

Thanks for your quick reply.
Regarding to your questions how to retrieve the id from the sql server, I
thought that i happens automatically like
when you are directly connected to the database, with the autogenerated code
it works without a problem.
I have solved the problem now like this:

Windows Form Code:
dt=WS.setPatients(dt);
dataGridView1.DataSource=dt;

WS Code:
[WebMethod]
public DSAcciGuard.PatientDataTable setPatients(DSAcciGuard.PatientDataTable
dt)
{
pta.Update(dt);
return dt;
}

Thanks for your support. Really appreciate it.


Werner

Miha Markic said:
Hi Werner,

Why don't you send over the DataTable.GetChanges() and return the same
data populated with server assigned ids?
How do you retrieve ID?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Werner Wopienka said:
Hi NG!

I've tried the sample walkthrough: Creating a Distrubited Application
with my database which includes a autoincrement value.

My problem is that i don't get the current autoincrement value from the
SQL Server when the table is empty. I clicked the save button whiches
sends the datatable via WS to the sql server but the id in the datatable
is incorrect.

The problem does not occur when i connect the windows app directly to the
sql server.
Is there any way to get the latest autoincrement value from the sql
server to set it correctly into the datatable?

thx 4 any help

Werner
Miha Markic said:
Hi Werner,

Why don't you send over the DataTable.GetChanges() and return the same
data populated with server assigned ids?
How do you retrieve ID?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Werner Wopienka said:
Hi NG!

I've tried the sample walkthrough: Creating a Distrubited Application
with my database which includes a autoincrement value.

My problem is that i don't get the current autoincrement value from the
SQL Server when the table is empty. I clicked the save button whiches
sends the datatable via WS to the sql server but the id in the datatable
is incorrect.

The problem does not occur when i connect the windows app directly to the
sql server.
Is there any way to get the latest autoincrement value from the sql
server to set it correctly into the datatable?

thx 4 any help

Werner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top