how to hadle database login failure in VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Prashanth
    New Member
    • Sep 2006
    • 4

    how to hadle database login failure in VB

    Hi,

    I am trying to connect to a database using a login.
    below are the statements regarding it.
    ............... ............... ............... ............... ...
    set con_to_exceptio n_database = New ADODB.Connectio n
    strConn = "Provider = SQLOLEDB.1;Pers ist Secutiry info= False; User ID= Sunny;Initial Catalog=Databas e;Data source = india".
    conn_to_excepti on_datbase.Mode = adModeReadWrite .
    conn_to_excepti on_datbase.Open strConn.
    ............... ............... ............... ............... ............... ...
    previously the user was valid now its no more valid..I am getting an error message as below.
    ............... ............... ............... ............... ............... ........
    Run-time error '-21474672559(800 04005)'
    Cannot Open database requested in login 'Database'.Logi n fails
    ............... ............... ............... ............... ............... ............... .
    I tried to hadle using "On Error GoTo Next_Database."
    This is working when debug... but when i run its not working.
    Can any one help me with this please.
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi there,

    kidly refer to the below modified code segment, check for naming convention.. take care my fren.. :)

    Code:
    On Error Goto DBErrorHandler
    
    set con_to_exception_database = New ADODB.Connection
    strConn = "Provider = SQLOLEDB.1;Persist Secutiry info= False; User ID= Sunny;Initial Catalog=Database;Data source = india".
    conn_to_exception_[B]datbase[/B].Mode = adModeReadWrite.
    conn_to_exception_[B]datbase[/B].Open strConn.
    
    DBErrorHandler:
      Msgbox "Error alert message goes here"
    Originally posted by Prashanth
    Hi,

    I am trying to connect to a database using a login.
    below are the statements regarding it.
    ............... ............... ............... ............... ...
    set con_to_exceptio n_database = New ADODB.Connectio n
    strConn = "Provider = SQLOLEDB.1;Pers ist Secutiry info= False; User ID= Sunny;Initial Catalog=Databas e;Data source = india".
    conn_to_excepti on_datbase.Mode = adModeReadWrite .
    conn_to_excepti on_datbase.Open strConn.
    ............... ............... ............... ............... ............... ...
    previously the user was valid now its no more valid..I am getting an error message as below.
    ............... ............... ............... ............... ............... ........
    Run-time error '-21474672559(800 04005)'
    Cannot Open database requested in login 'Database'.Logi n fails
    ............... ............... ............... ............... ............... ............... .
    I tried to hadle using "On Error GoTo Next_Database."
    This is working when debug... but when i run its not working.
    Can any one help me with this please.

    Comment

    Working...