1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
Dim nom_sql_serveur = Nom_Serveur_SQL.Text
Dim Connexion As SqlConnection
If (Type_authentification_SQL.SelectedItem = "Authentification SQL Serveur") Then
' MsgBox(nom_sql_serveur)
Dim user = Nom_utilisateur_SQL.Text
Dim mdp = mdp_utilisateur_SQL.Text
Connexion = New SqlConnection("Data Source=" & nom_sql_serveur & ";User Id=" & user & ";Password=" & mdp & ";")
Else
' MsgBox(nom_sql_serveur)
Nom_utilisateur_SQL.Enabled = "False"
mdp_utilisateur_SQL.Enabled = "false"
Connexion = New SqlConnection("Data Source=" & nom_sql_serveur & ";Integrated Security=SSPI;")
End If
Try
Connexion.Open()
If (Connexion.State = "1") Then
Resultat_connexion_sqlserveur.Text = "Connexion au serveur SQL Réussie!"
End If
'MsgBox("Etat de la connexion : " & Connexion.State)
Dim Requete As String = "EXEC sp_databases"
Dim Commande As New SqlCommand(Requete, Connexion)
Dim Adaptateur As New SqlDataAdapter(Commande)
Dim MonDataSet As New DataSet
Adaptateur.Fill(MonDataSet, "BDD")
For Each Ligne As DataRow In MonDataSet.Tables("BDD").Rows()
ComboBox_list_bdd.Items.Add(Ligne("DATABASE_NAME"))
'resultat_list_bdd.Items.Add(Ligne("DATABASE_NAME"))
'Console.WriteLine(Ligne("Artiste").ToString & " - " & Ligne("Titre").ToString)
Next
Try
' MsgBox("Il y a eu " & Commande.ExecuteNonQuery() & " lignes mises à jour")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Commande.Dispose()
Connexion.Close()
Catch ex As Exception
' MsgBox("L'erreur suivante a été rencontrée :" & ex.Message)
' Resultat_connexion_sqlserveur.Text = "1-L'erreur suivante a été rencontrée :" & vbCrLf & ex.Message
End Try
Connexion.Close() |
Partager