Results 1 to 2 of 2

Thread: Ado Error -2147217887

  1. #1
    Guest

    Post

    I am using SQLServer 6.5 as a Backend and VB 6 prof. And I am using ADO 2.1 with SQLOLEDB provider. Whenever I try to make any chages to the database and if it violates any constraint I get geneal error. " -2147217887 Errors occurred" . If I want specific error info like Primary key violation or Check constraint violation or specific error info from a trigger. How do I do that. With this general error I don't have a clue. I have used Connection objects error collection but that don't give me specific error information.

    Thanks in Advance,
    Anagha

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    You can use Errors collection to get all errors:

    Code:
        Dim cn As New ADODB.Connection
        Dim i As Integer
        
        On Error Resume Next
    
        cn.ConnectionString = "DSN=MyDSN;UID=sa;PWD=;"
        cn.Open
        
        cn.Execute "Update MyTable Set MyField = MyValue"
        For i = 0 To cn.Errors.Count - 1
            Debug.Print cn.Errors(i).Description
        Next
    Regards,

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]




    [This message has been edited by Serge (edited 10-22-1999).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width