Getting the counter value after an addnew-SQL SERVER 2000/ADO 
Author Message
 Getting the counter value after an addnew-SQL SERVER 2000/ADO

I am using SQL Server 2000 and am having problems with the code I have been
using forever with SQL 7 and now it is not working.  Here is the deal...

I am doing an update on data that has just been inserted into the database.
In order to get the value of the ID I set the bookmark to the existing
bookmark and get the ID after that movement.  No more.  I get the following
error...

"Provider cannot determine the value. Possible reasons: The record was just
created, the default value for the field was not available, or the user has
not set a new value."

The following code was executed...
rsData.Open strSQL, DB_CONNECT, adOpenKeyset, adLockOptimistic
    If mudtProps.m_isNew Then rsData.AddNew
    'fill data fields
    With rsData
        .Fields("CC_DESC") = Trim$(mudtProps.m_desc) & sEmpty
        .Update
        If mudtProps.m_isNew Then
            .Bookmark = .Bookmark
            mudtProps.m_id = .Fields("CC_ID")
        End If
        .Close
    End With

It is blowing up on the line that says .Bookmark = .Bookmark

Thanks for any answers to this problem or any suggestions to do it another
way.

Respectfully,

Bob Hansen



Sun, 24 Aug 2003 00:53:19 GMT  
 Getting the counter value after an addnew-SQL SERVER 2000/ADO
Bob,
Take a look at the following ADO FAQ
http://www.able-consulting.com/ADO_Faq.htm#Q9

--

Thanks,
Carl Prothman
Microsoft Visual Basic MVP
http://www.able-consulting.com


Quote:
> I am using SQL Server 2000 and am having problems with the code I have
been
> using forever with SQL 7 and now it is not working.  Here is the deal...

> I am doing an update on data that has just been inserted into the
database.
> In order to get the value of the ID I set the bookmark to the existing
> bookmark and get the ID after that movement.  No more.  I get the
following
> error...

> "Provider cannot determine the value. Possible reasons: The record was
just
> created, the default value for the field was not available, or the user
has
> not set a new value."

> The following code was executed...
> rsData.Open strSQL, DB_CONNECT, adOpenKeyset, adLockOptimistic
>     If mudtProps.m_isNew Then rsData.AddNew
>     'fill data fields
>     With rsData
>         .Fields("CC_DESC") = Trim$(mudtProps.m_desc) & sEmpty
>         .Update
>         If mudtProps.m_isNew Then
>             .Bookmark = .Bookmark
>             mudtProps.m_id = .Fields("CC_ID")
>         End If
>         .Close
>     End With

> It is blowing up on the line that says .Bookmark = .Bookmark

> Thanks for any answers to this problem or any suggestions to do it another
> way.

> Respectfully,

> Bob Hansen



Sun, 24 Aug 2003 13:24:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VB6: Oracle 8/SQL Server 2000 compatibility problems using ADO 2.5 and SQL

2. VB6: Oracle 8/SQL Server 2000 compatibility problems using ADO 2.5 and SQL Syntax

3. VB6: Oracle 8/SQL Server 2000 compatibility problems using ADO 2.5 and SQL Syntax

4. Getting a return value from a SP (SQL 2000, VB 6.0)

5. Access counter field value during AddNew

6. Access counter field value during AddNew

7. Counter Fields - value assigned on Addnew not Update?

8. HELP!!!!, using ADO + SQL 2000 + Stored procedures does not return a value

9. HELP!!!!, using ADO + SQL 2000 + Stored procedures does not return a value

10. ADO.AddNew and SQL Server Identity Field

11. AddNew Question, ADO / SQL Server

12. ADDNEW-Method on ADO with SQL-Server [Newbie]

 

 
Powered by phpBB® Forum Software