achrefghanmi
8Messages postés
5 février 2010Date d'inscription
22 avril 2010Dernière intervention
15 avril 2010 à 14:17
voila tout d'abord les imports :on doit importer des classes dans notre projet
Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.Sql
public class nom_classe
Public Function Connecter() 'Voici une fonction de connection
Dim w As Boolean
conn = New SqlConnection()
conn.ConnectionString = "Data Source=localhost;Initial Catalog=nom_base_donné";integrated security=true"
Try
conn.Open()
w = True
Catch ex As Exception
MsgBox("connection echoué !!! ")
w = False
End Try
Return w
End Function
'fonction pour la recgercg et la recuperation des donnée:
Public Sub rechercheuser()
Dim table As New DataTable
sql = "select * from om_table where blabla='" &blabla & "' and pwd ='" & pwd & "'"
command.Connection = conn
command.CommandText = sql
Try
adapter.SelectCommand = command
adapter.Fill(table)
For i As Integer = 0 To table.Rows.Count - 1
combobox.item.add ( table.Rows(i)("login"))
Next
Catch
MsgBox("Probleme inattendue !!!")
End Try
End Sub
' voici une fonction pour l'insertion
Public Sub nom_fnction()
Try
sql = "insert into nom_tabler values ('" & nam & "','" & pad & "','" & typ & "')"
command.Connection = conn
command.CommandText = sql
command.ExecuteNonQuery()
MsgBox("Ajout utilisateur terminé", MsgBoxStyle.Information, "Vérfification d'utilisateur")
Catch ex As System.Data.SqlClient.SqlException
MsgBox( ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
' par la suite vous ne faite que d'appeler ces fonctions
- sous quelle version de vb.net
car il me signale bcp d'erreurs