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
| ' ===================================================================
' Execution requete générique SQL de type SELECT
' Paramètres : strSql = Requête Sql à exécuter
' Retourne : DataReader
' Fonction qui doit appeler la bonne fonction selon le paramétrage
' ===================================================================
Public Function Sql_Select(ByVal strSql)
If nTypeBDD = BDD_SQLSERVER Then
Sql_Select = SqlServer_Select(strSql)
ElseIf nTypeBDD = BDD_MYSQL Then
Sql_Select = MySql_Select(strSql)
ElseIf nTypeBDD = BDD_ODBC Then
Sql_Select = Odbc_Select(strSql)
Else
Sql_Select = OleDb_Select(strSql)
End If
End Function
' ===================================================================
' Execution requete SQL BDD SQLServer
' Paramètres : strSql = Requête Sql à exécuter
' Retourne : RecordSet
' ===================================================================
Public Function SqlServer_Select(ByVal strSql) As SqlClient.SqlDataReader ' voir common.dbDatareader
oCn.ConnectionString = "Data Source=" & strServer & ";User Id=sa ;Initial Catalog=" & strDatabase & ";Connection TimeOut=10"
oCn.Open()
'
Dim rdSql As New SqlClient.SqlCommand
rdSql.Connection = oCn
rdSql.CommandType = CommandType.Text
rdSql.CommandText = strSql
Dim MyReader As SqlClient.SqlDataReader
MyReader = rdSql.ExecuteReader
SqlServer_Select = MyReader
End Function
Public Function MySql_Select(ByVal strSql) 'As SqlClient.SqlDataReader
...... |
Partager