hello guys!

Its been a long time posting here since I've switch to dot net...But I CANT LEAVE VB6 in programming.!

I just want a little help.. Anybody can recode this statement regarding connecting to SQL SERVER local database.. The connection is succesful. But i want to trap the error when the program is disconnected to SQL server DB or the program has failed to connect to sql server. I want the error to be displayed on the message box then i want to show the login form named(logfrm) again. Thank you guys for giving time.! Heres my code..

IN MODULE.................

Public objCommand As New ADODB.Command
Public objrs As New ADODB.Recordset
Public conn As New ADODB.Connection
Public strConnection, Password, User, InitialC, Source As String

'FUNCTION USED TO CONNECT TO OUR SQL SERVER(can be modified anytime depending on SQL SERVER VERSION)

Sub sqlconnection()
    Source = "localhost"                        'our SQL server host
    User = ""                                   'user name
    Password = ""                               'password if applicable
    InitialC = "DB_Merchandise"                'Our database
    
    strConnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" & "Password=" &   Password & ";User ID=" & User & ";Initial Catalog=" & InitialC & ";Data Source=" & Source

Have you tried handling the error using ON ERROR and then tired to find out what is the error number or message is ?

Thank you for both suggestions........Ill try both of it today.. Ill post the result later..

Thank you guys...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.