Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQLOLEDB .AddNew & .Value Error

Author  Topic 

joe iacoponi
Starting Member

11 Posts

Posted - 2002-04-08 : 21:23:01
I just recently switched from a DSN connection to a SQLOLEDB connection to my SQL 7 server from ASP.

We immediately started having a problem with one specific .AddNew Method while requesting a .Value return on the Identity. The return value is now zero instead of the correct record inserted.

Interestingly, I have an almost identical process in another ASP program that works fine. The program flow is somewhat different, but the connection is the same:

Set OBJdbConnection = Server.CreateObject("ADODB.Connection")
OBJdbConnection.Open "Provider=SQLOLEDB; Data Source=127.0.0.1; Initial Catalog=Mydb; User ID=MyID; Password=MyPW"

Set rsAddHeader = Server.CreateObject("ADODB.Recordset")
rsAddHeader.ActiveConnection = OBJdbConnection
rsAddHeader.CursorLocation = 3 'adUseClient
rsAddHeader.CursorType = 1 'adOpenKeyset
rsAddHeader.LockType = 3 'adLockOptimistic
rsAddHeader.Source = "ItemHeader"
rsAddHeader.Open

rsAddHeader.AddNew
rsAddHeader("ItemType") = ItemType
rsAddHeader("ItemDate") = Now()
rsAddHeader("StatusCode") = "R"
rsAddHeader("StatusDate") = Now()
rsAddHeader("ItemType") = 1
rsAddHeader.Update

Session("ItemNumber") = rsAddHeader.Fields("ItemNumber").Value

Response.Write "ItemNumber: " & Session("ItemNumber")

Anybody have any idea what might be causing this bizarre problem???


Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-04-08 : 22:35:03
Hi

Instead of your "source " parameter, try

rs.open "Select * from Table WHERE 1=0"

and see what that gives you.

Damian
Go to Top of Page
   

- Advertisement -