This code defines classes and methods for connecting to a database and executing SQL commands. It declares variables for a connection string, command, and data reader. The proc_connexion method opens a connection, creates a command, and executes a reader. The pro_deconnexion method closes the connection and reader. The la_table method opens a connection, executes a command, fills a data table, and returns the table.
This code defines classes and methods for connecting to a database and executing SQL commands. It declares variables for a connection string, command, and data reader. The proc_connexion method opens a connection, creates a command, and executes a reader. The pro_deconnexion method closes the connection and reader. The la_table method opens a connection, executes a command, fills a data table, and returns the table.
This code defines classes and methods for connecting to a database and executing SQL commands. It declares variables for a connection string, command, and data reader. The proc_connexion method opens a connection, creates a command, and executes a reader. The pro_deconnexion method closes the connection and reader. The la_table method opens a connection, executes a command, fills a data table, and returns the table.
Public cnn As SqlConnection Private macon = New OleDbConnection 'Déclare une variable macon de type oledb connexion et instanciée(New) Public rdr As OleDbDataReader Private strcon As String Private cmd As OleDbCommand Public mareq As String
'procédure permetant de faire la connexion et d'exécuter les commandes sql
Public Sub proc_connexion() strcon = connect 'permet la connexion à la bd macon = New OleDbConnection(strcon) macon.open() cmd = New OleDbCommand(mareq, macon) rdr = cmd.ExecuteReader() End Sub Public Sub pro_deconnexion() rdr.Close() macon.close() End Sub
Public Function la_table() As DataTable
strcon = connect 'permet la connexion à la bd macon = New OleDbConnection(strcon) macon.open() cmd = New OleDbCommand(mareq, macon) ' Dim dt As New DataSet Dim ds As DataTable = New DataTable Dim dat As New OleDbDataAdapter(cmd) dat.Fill(ds) 'ds = dt.Tables(0) macon.close() Return (ds) End Function