I'm trying to fill an array from a query on a table but I don't know how to turn the variable "CentreName" into a parameter of the query (obviously the sql string I presently have doesn't work).
Code:Public Function db_GetClassDays(ByVal ManagerName, ByVal CentreName) As Array Dim Conn As OleDbConnection Dim ds As New DataSet Dim da As OleDbDataAdapter Dim SQL As String Dim ConnectionString As String Dim ClassDays(gMaxCentres) As String ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & My.Settings.AppPath & "\" & ManagerName & "_FCLManager2011_Centres.mdb" SQL = "SELECT * FROM tblCentre_Details WHERE Centre_Name = CentreName ORDER by ID" Conn = New OleDbConnection(ConnectionString) Try Conn.Open() da = New OleDbDataAdapter(SQL, Conn) da.Fill(ds) da.Dispose() Conn.Close() 'now some code here to fill ClassDays with data from the dataset Catch ex As Exception MsgBox("Cannot open connection ! ") End Try Return ClassDays End Function




Reply With Quote