[Vb.net] cree module de connexion?(sqlserver)

Fermé
gezaakk Messages postés 380 Date d'inscription jeudi 27 mai 2010 Statut Membre Dernière intervention 26 mai 2015 - Modifié par gezaakk le 3/06/2011 à 17:33
gezaakk Messages postés 380 Date d'inscription jeudi 27 mai 2010 Statut Membre Dernière intervention 26 mai 2015 - 3 juin 2011 à 21:23
Bonjour,
Je voudrais créer un module qui permette d'automatiser la création d'une connexion vers mon SQLServer. Sans avoir a marquer en dur a chaque fois ma chaine de connexion dans le code.

Voici comment je me connecte a ma base sql server:


Dim MyConnexion As SqlConnection = New SqlConnection("Data Source=.\sqlexpress;" & _
"Integrated Security=SSPI;Initial Catalog=autoecole")
Dim Mycommand As SqlCommand = MyConnexion.CreateCommand()
Mycommand.CommandText = "SELECT * FROM utilisateur where typ_uti='" + Type.Text + "'"
MyConnexion.Open()
Dim myReader As SqlDataReader = Mycommand.ExecuteReader()
myReader.Read()
....
pass.Text = myReader.GetValue(2)
....
MyConnexion.Close()



Merci d'avance
A voir également:

1 réponse

gezaakk Messages postés 380 Date d'inscription jeudi 27 mai 2010 Statut Membre Dernière intervention 26 mai 2015 34
3 juin 2011 à 21:23
y a pas une solution?
je met quoi dans le module et comment je l'appel dans mes forme?
merci
-1