codice:
Public Sub ConnettiSQLServer(ByVal User As String, 
ByVal Pwd As String)   
       
' Connessione al database GITS.         
Try             
' Stringa di connessione.             
objConnessione.ConnectionString = 
"Data Source = TURING\SQLEXPRESS; 
 Database=GITS; 
 User ID=" & User & ";" "Password=" & Pwd & ";" "

' Visualizza il form Main e nascondi il form Login.             
Main.Show()             
Login.Hide()              

' Eccezioni SQLServer.        
 Catch SqlEx As SqlException              

Select Case SqlEx.Number
                 
' Utente o password errata.                 
Case 18456                     
MsgBox("Utente o password errata.", MsgBoxStyle.Information)                      


' Utente disattivato.                 
Case 18470                     
MsgBox("Utente disattivato.", MsgBoxStyle.Information)             
End Select              

Login.txtPassword.Text = ""

Exit Sub          

End Try      

End Sub