Showing posts with label situation. Show all posts
Showing posts with label situation. Show all posts

Wednesday, March 21, 2012

Read autonumbering field from db

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=xxxx
xx"
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 :-)Take a look at the @.@.IDENTITY, SCOPE_IDENTITY and IDENT_CURRENT functions fo
r
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=xxxx
xx"
> 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 :-)
>|||THANKs Mark - will do saturday morning.
Right now and here: Is there a command we need to add ?
Best regards
Jens
"Mark Williams" wrote:
> Take a look at the @.@.IDENTITY, SCOPE_IDENTITY and IDENT_CURRENT functions
for
> SQL server in Books Online.
> --
>
> "Jensgjerloev" wrote:
>|||THANKX Mark - it's working now - thanks to your help :-))
Best Regards
Jens
"Mark Williams" wrote:
> Take a look at the @.@.IDENTITY, SCOPE_IDENTITY and IDENT_CURRENT functions
for
> SQL server in Books Online.
> --
>
> "Jensgjerloev" wrote:
>