Home All Groups Group Topic Archive Search About

Read autonumbering field from db

Author
10 Feb 2006 5:02 PM
Jensgjerloev
Situation: We are blank new to SQL server (previosuly access) and we need to
convert to sql server quickly. Consequently this is maybe not a very wice
question - but it is SO important to us :-)
**
this works in access - but not on sql server:

Tabel contains 2 fields:
id = autonumbering
text = textfield
****
Set Con = CreateObject(”ADODB.Connection
Con.open "PROVIDER=SQLOLEDB;DATA
SOURCE=192.168.2xx.xx;UID=xxxxxx;PWD=xxxxxxxx;DATABASE=xxxxxx"
Set RS=CreateObject(”ADODB.RecordSet”)
RS.Open ”Select * FROM test”, 1, 3
RS.AddNew
RS(”Text”) = ”test tekst”
RS.Update
Response.write RS(”text”) & ”was given id=” & RS(”id”)
RS.Close
Con.Close
’*********************************************************
this should output the given id number - which is actually IN the database.
But in the output from above - it is blank ...
Thanx in advance :-)

Author
10 Feb 2006 5:19 PM
Mark Williams
Take a look at the @@IDENTITY, SCOPE_IDENTITY and IDENT_CURRENT functions for
SQL server in Books Online.

--


Show quoteHide quote
"Jensgjerloev" wrote:

> Situation: We are blank new to SQL server (previosuly access) and we need to
> convert to sql server quickly. Consequently this is maybe not a very wice
> question - but it is SO important to us :-)
> **
> this works in access - but not on sql server:
>
> Tabel contains 2 fields:
> id = autonumbering
> text = textfield
> ****
> Set Con = CreateObject(”ADODB.Connection
> Con.open "PROVIDER=SQLOLEDB;DATA
> SOURCE=192.168.2xx.xx;UID=xxxxxx;PWD=xxxxxxxx;DATABASE=xxxxxx"
> Set RS=CreateObject(”ADODB.RecordSet”)
> RS.Open ”Select * FROM test”, 1, 3
> RS.AddNew
> RS(”Text”) = ”test tekst”
> RS.Update
> Response.write RS(”text”) & ”was given id=” & RS(”id”)
> RS.Close
> Con.Close
> ’*********************************************************
> this should output the given id number - which is actually IN the database.
> But in the output from above - it is blank ...
> Thanx in advance :-)
>
>
Are all your drivers up to date? click for free checkup

Author
10 Feb 2006 5:29 PM
Jensgjerloev
THANKs Mark - will do saturday morning.
Right now and here: Is there a command we need to add ?

Best regards
Jens

Show quoteHide quote
"Mark Williams" wrote:

> Take a look at the @@IDENTITY, SCOPE_IDENTITY and IDENT_CURRENT functions for
> SQL server in Books Online.
>
> --
>
>
> "Jensgjerloev" wrote:
>
> > Situation: We are blank new to SQL server (previosuly access) and we need to
> > convert to sql server quickly. Consequently this is maybe not a very wice
> > question - but it is SO important to us :-)
> > **
> > this works in access - but not on sql server:
> >
> > Tabel contains 2 fields:
> > id = autonumbering
> > text = textfield
> > ****
> > Set Con = CreateObject(”ADODB.Connection
> > Con.open "PROVIDER=SQLOLEDB;DATA
> > SOURCE=192.168.2xx.xx;UID=xxxxxx;PWD=xxxxxxxx;DATABASE=xxxxxx"
> > Set RS=CreateObject(”ADODB.RecordSet”)
> > RS.Open ”Select * FROM test”, 1, 3
> > RS.AddNew
> > RS(”Text”) = ”test tekst”
> > RS.Update
> > Response.write RS(”text”) & ”was given id=” & RS(”id”)
> > RS.Close
> > Con.Close
> > ’*********************************************************
> > this should output the given id number - which is actually IN the database.
> > But in the output from above - it is blank ...
> > Thanx in advance :-)
> >
> >
Author
12 Feb 2006 2:11 PM
Jensgjerloev
THANKX Mark - it's working now - thanks to your help :-))
Best Regards
Jens

Show quoteHide quote
"Mark Williams" wrote:

> Take a look at the @@IDENTITY, SCOPE_IDENTITY and IDENT_CURRENT functions for
> SQL server in Books Online.
>
> --
>
>
> "Jensgjerloev" wrote:
>
> > Situation: We are blank new to SQL server (previosuly access) and we need to
> > convert to sql server quickly. Consequently this is maybe not a very wice
> > question - but it is SO important to us :-)
> > **
> > this works in access - but not on sql server:
> >
> > Tabel contains 2 fields:
> > id = autonumbering
> > text = textfield
> > ****
> > Set Con = CreateObject(”ADODB.Connection
> > Con.open "PROVIDER=SQLOLEDB;DATA
> > SOURCE=192.168.2xx.xx;UID=xxxxxx;PWD=xxxxxxxx;DATABASE=xxxxxx"
> > Set RS=CreateObject(”ADODB.RecordSet”)
> > RS.Open ”Select * FROM test”, 1, 3
> > RS.AddNew
> > RS(”Text”) = ”test tekst”
> > RS.Update
> > Response.write RS(”text”) & ”was given id=” & RS(”id”)
> > RS.Close
> > Con.Close
> > ’*********************************************************
> > this should output the given id number - which is actually IN the database.
> > But in the output from above - it is blank ...
> > Thanx in advance :-)
> >
> >

Bookmark and Share