Home All Groups Group Topic Archive Search About

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

Author
1 May 2006 4:20 PM
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

Author
1 May 2006 5:19 PM
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?

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

Show quote
"Werner Wopienka" <werner_wopie***@hotmail.com> wrote in message
news:emyQksTbGHA.3524@TK2MSFTNGP04.phx.gbl...
> 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
>
>
>
Author
1 May 2006 6:21 PM
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

Show quote
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:O$sA3NUbGHA.472@TK2MSFTNGP05.phx.gbl...
> 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" <werner_wopie***@hotmail.com> wrote in message
> news:emyQksTbGHA.3524@TK2MSFTNGP04.phx.gbl...
>> 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 [MVP C#]" <miha at rthand com> wrote in message
news:O$sA3NUbGHA.472@TK2MSFTNGP05.phx.gbl...
> 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" <werner_wopie***@hotmail.com> wrote in message
> news:emyQksTbGHA.3524@TK2MSFTNGP04.phx.gbl...
>> 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
>>
>>
>>
>
>
Author
1 May 2006 5:37 PM
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/default.asp?url=/library/en-us/vsintro7/html/vbwlkCreatingDistributedWebApplicationWalkthrough.asp

I hope that helps,

Cor

Show quote
"Werner Wopienka" <werner_wopie***@hotmail.com> schreef in bericht
news:emyQksTbGHA.3524@TK2MSFTNGP04.phx.gbl...
> 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
>
>
>

AddThis Social Bookmark Button