Imports System.Data Imports System.Data.Odbc Dim strSQL As String Dim objRecordSet As Odbc.OdbcDataReader strSQL = "select t.id as UNITTYPEID ,t.name AS NAME, u.id as UNITCONTENTID" _ & " from sys_aunittypes_c t, sys_cunitsincappfile_c u,sys_ccappfiles_c f" _ & " Where F.id = u.CAPPFileID And u.UnitTypeID = t.id AND f.id = " & lngCappFileID _ & " order by u.unitorder" objRecordSet = GetDataReader(strSQL) While (objRecordSet.Read()) lUnitContentID = CLng(objRecordSet.Item("UNITCONTENTID").ToString) lUnitTypeID = CLng(objRecordSet.Item("UNITTYPEID").ToString) strUnitName = objRecordSet.Item("NAME").ToString End While objRecordSet.Close() Public Function GetDataReader(ByVal strSql As String) As Odbc.OdbcDataReader On Error GoTo ErrRet GetDataReader = Nothing Dim objDataReader As Odbc.OdbcDataReader 'Public g_objEntityConn As Odbc.OdbcConnection g_objEntityConn = New OdbcConnection(g_strConnectString) If g_objEntityConn.State = ConnectionState.Closed Then g_objEntityConn.Open() End If If g_objEntityConn Is Nothing Then Exit Function End If Dim cmm As OdbcCommand cmm = New OdbcCommand(strSql, g_objEntityConn) objDataReader = cmm.ExecuteReader(CommandBehavior.CloseConnection) GetDataReader = objDataReader Exit Function ErrRet: MsgBox(Err.Description) End Function