Chaine de connection SQL SERVER en VB.net
Fermé
Tung
Messages postés
187
Date d'inscription
jeudi 7 février 2008
Statut
Membre
Dernière intervention
20 août 2013
-
Modifié par Tung le 13/07/2011 à 20:16
Tung Messages postés 187 Date d'inscription jeudi 7 février 2008 Statut Membre Dernière intervention 20 août 2013 - 17 juil. 2011 à 19:48
Tung Messages postés 187 Date d'inscription jeudi 7 février 2008 Statut Membre Dernière intervention 20 août 2013 - 17 juil. 2011 à 19:48
A voir également:
- Chaine de connection SQL SERVER en VB.net
- Chaine tnt gratuite sur mobile - Guide
- Gmail connection - Guide
- Plus de chaine tv - Guide
- Ps3 media server - Télécharger - Divers Réseau & Wi-Fi
- Nouvelle chaîne tnt gratuite 2024 - Accueil - TV & Vidéo
1 réponse
bonjour,
dans vb.net 8 je fais comme ca:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Module Module1
Friend con As SqlConnection
Sub Brancher()
Dim PWD As String
Dim Suser As String
Dim Srv As String
PWD = "cogito"
Suser = "sa"
Srv = "HAMRIS\SQLEXPRESS"
con = New SqlConnection("Data Source=.\SQLEXPRESS;Password=" & PWD & ";Persist Security Info=true;User ID=" & Suser & ";Initial Catalog=G_TICKETS;Data Source=" & Srv & "")
End Sub
'connexion
Public Sub Connect()
Try
con.Open()
Catch ex As Exception
con.Close()
con.Open()
End Try
End Sub
'deconnexion
Public Sub Deconnect()
Try
con.Close()
Catch ex As Exception
con.Open()
con.Close()
End Try
End Sub
End Module
et en vb6 je fais comme ca:
Public Con As New ADODB.Connection
Public Usario, TpUser As String
Public ErrDt As Boolean
Public D_R, D_A, F_R, F_A, F_F, BL_C, BL_F, V_C, B_C, D_P, Av_C, Av_F, R_C, R_F, S_C, S_F, Ch_C, Ch_F As Boolean
Public Cas_Modif, Ref_Rep As Boolean
'Public Err_con As Boolean
Public Sub Brancher()
Dim sConnect As String
Dim PWD As String
Dim Suser As String
Dim Srv As String
On Error GoTo err_cnparc
PWD = "cogito"
Suser = "sa"
'Srv = "HAMRIS\SQLEXPRESS"
'Srv = ".\SQLEXPRESS"
Srv = "192.168.1.10\SQLEXPRESS"
'Srv = "IRRITER\SQLEXPRESS"
Con = "Provider=SQLOLEDB.1;Password=" & PWD & ";Persist Security Info=true;User ID=" & Suser & ";Initial Catalog=IRRI_TER;Data Source=" & Srv
Con.Open
If Con.State = adStateOpen Then
'MsgBox "Connexion ok "
Else
MsgBox "Connexion impossible "
End If
err_cnparc:
If Con.State <> adStateOpen Then
MsgBox Err.Description, vbOKOnly + vbExclamation, "Erreur de connexion"
'Err_con = True
'Ressayer_Connexion.Show
End If
End Sub
_____________________
mais pour voir tous les types de connexions au bd voir ca:
http://www.connectionstrings.com/
bonne courage.
dans vb.net 8 je fais comme ca:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Module Module1
Friend con As SqlConnection
Sub Brancher()
Dim PWD As String
Dim Suser As String
Dim Srv As String
PWD = "cogito"
Suser = "sa"
Srv = "HAMRIS\SQLEXPRESS"
con = New SqlConnection("Data Source=.\SQLEXPRESS;Password=" & PWD & ";Persist Security Info=true;User ID=" & Suser & ";Initial Catalog=G_TICKETS;Data Source=" & Srv & "")
End Sub
'connexion
Public Sub Connect()
Try
con.Open()
Catch ex As Exception
con.Close()
con.Open()
End Try
End Sub
'deconnexion
Public Sub Deconnect()
Try
con.Close()
Catch ex As Exception
con.Open()
con.Close()
End Try
End Sub
End Module
et en vb6 je fais comme ca:
Public Con As New ADODB.Connection
Public Usario, TpUser As String
Public ErrDt As Boolean
Public D_R, D_A, F_R, F_A, F_F, BL_C, BL_F, V_C, B_C, D_P, Av_C, Av_F, R_C, R_F, S_C, S_F, Ch_C, Ch_F As Boolean
Public Cas_Modif, Ref_Rep As Boolean
'Public Err_con As Boolean
Public Sub Brancher()
Dim sConnect As String
Dim PWD As String
Dim Suser As String
Dim Srv As String
On Error GoTo err_cnparc
PWD = "cogito"
Suser = "sa"
'Srv = "HAMRIS\SQLEXPRESS"
'Srv = ".\SQLEXPRESS"
Srv = "192.168.1.10\SQLEXPRESS"
'Srv = "IRRITER\SQLEXPRESS"
Con = "Provider=SQLOLEDB.1;Password=" & PWD & ";Persist Security Info=true;User ID=" & Suser & ";Initial Catalog=IRRI_TER;Data Source=" & Srv
Con.Open
If Con.State = adStateOpen Then
'MsgBox "Connexion ok "
Else
MsgBox "Connexion impossible "
End If
err_cnparc:
If Con.State <> adStateOpen Then
MsgBox Err.Description, vbOKOnly + vbExclamation, "Erreur de connexion"
'Err_con = True
'Ressayer_Connexion.Show
End If
End Sub
_____________________
mais pour voir tous les types de connexions au bd voir ca:
http://www.connectionstrings.com/
bonne courage.
17 juil. 2011 à 19:48