Supports odbc connection for mssql , dBASE, MS Excel, MS FOX, MS Access, MySQL and Text db (through text driver)
for FB 0.17b -lang fb
FBODBC.bi :
Code: Select all
'*************************************************************
' FB ODBC Library
'
'by Leonardo Neumann aka 'KaraK'
'karak.neumann at gmail dot com
'*************************************************************
#Include Once "win/sqltypes.bi"
#Include Once "win/sql.bi"
#Include Once "win/sqlext.bi"
#Include Once "win/odbcinst.bi"
Namespace FBODBC
Enum EnumProtocols
protoNamedPipes
protoWinSock
protoIPX
protoBanyan
protoRPC
End Enum
'Object
Type ODBCConnection
Public:
Declare Constructor()
Declare Destructor()
Declare Function Connect(svSource As String) As Boolean
Declare Function ConnectDSN(DSN As String,User as String="",Pass As String="") As Boolean
Declare Sub Disconnect()
Declare Function DBC() As HDBC
'MSSQL
Declare Function MSSQLConnect(User As String,Pass As String,Host As String = "(local)",Trusted As Boolean = TRUE,Proto As EnumProtocols = protoNamedPipes) As Boolean
'dBASE
Declare Function DB2Connect(DBPath As String) As Boolean
'MS Excel
Declare Function XLSConnect(XLSPath As String,DefDir As String = "") As Boolean
'Text
Declare Function TXTConnect(TXTPath As String) As Boolean
'MS FOX
Declare Function FOXConnect(DBPath As String,User As String = "",Pass As String = "",SrcType As String = "DBF",Exclusive As Boolean = FALSE) As Boolean
'MS Access
Declare Function MDBConnect(MDBPath As String,User As String = "",Pass As String = "",Exclusive As Boolean = FALSE) As Boolean
'MySQL
Declare Function MySQLConnect(User As String = "",Pass As String = "",Host As String = "localhost",Port As UInteger = 3306) As Boolean
Declare Function MySQLConnectDB(DB As String,User As String = "",Pass As String = "",Host As String = "localhost",Port As UInteger = 3306) As Boolean
Private:
m_nReturn As SQLRETURN 'Internal SQL Error code
m_hEnv As HENV 'Handle to environment
m_hDBC As HDBC 'Handle to database connection
End Type
Constructor ODBCConnection()
this.m_hDBC = NULL
this.m_hEnv = NULL
this.m_nReturn = SQL_ERROR
End Constructor
Destructor ODBCConnection()
If this.m_hDBC <> NULL Then
this.m_nReturn = SQLFreeHandle(SQL_HANDLE_DBC,this.m_hDBC)
EndIf
If this.m_hEnv <> NULL Then
this.m_nReturn = SQLFreeHandle(SQL_HANDLE_ENV,this.m_hEnv)
EndIf
End Destructor
Function ODBCConnection.Connect(svSource As String) As Boolean
Dim nConnect As Integer
nConnect = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,@this.m_hEnv)
if nConnect = SQL_SUCCESS Or nConnect = SQL_SUCCESS_WITH_INFO Then
nConnect = SQLSetEnvAttr(this.m_hEnv,SQL_ATTR_ODBC_VERSION,CPtr(Any ptr,SQL_OV_ODBC3),0)
if nConnect = SQL_SUCCESS Or nConnect = SQL_SUCCESS_WITH_INFO Then
nConnect = SQLAllocHandle(SQL_HANDLE_DBC,this.m_hEnv,@this.m_hDBC)
if nConnect = SQL_SUCCESS Or nConnect = SQL_SUCCESS_WITH_INFO Then
SQLSetConnectOption( this.m_hDBC,SQL_LOGIN_TIMEOUT,5 )
Dim shortResult As Short = 0
Dim szOutConnectString(1023) As SQLTCHAR
nConnect = SQLDriverConnect(m_hDBC,_ 'Conn Handle
NULL,_ 'window handle
CPtr(SQLTCHAR ptr,StrPtr(svSource)),_ 'InConnectionString
Len(svSource),_ 'StringLEnght1
@szOutConnectString(0),_ 'OutConnectionString
SizeOf(szOutConnectString),_ 'Buff len
@shortResult,_ 'StringLenght2Ptr
SQL_DRIVER_NOPROMPT) 'no user prompt
if nConnect = SQL_SUCCESS Or nConnect = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
EndIf
EndIf
EndIf
If this.m_hDBC <> NULL Then
this.m_nReturn = SQLDisconnect(this.m_hDBC)
this.m_nReturn = SQLFreeHandle(SQL_HANDLE_DBC,this.m_hDBC)
EndIf
If this.m_hEnv <> NULL Then
this.m_nReturn = SQLFreeHandle(SQL_HANDLE_ENV,this.m_hEnv)
this.m_hDBC = NULL
this.m_hEnv = NULL
this.m_nReturn = SQL_ERROR
EndIf
Return FALSE
End Function
Function ODBCConnection.ConnectDSN(DSN As String,User As String = "",Pass As String="") As Boolean
Dim nConnect As Integer
nConnect = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,@this.m_hEnv)
if nConnect = SQL_SUCCESS Or nConnect = SQL_SUCCESS_WITH_INFO Then
nConnect = SQLSetEnvAttr(this.m_hEnv,SQL_ATTR_ODBC_VERSION,SQL_OV_ODBC3,SQL_IS_INTEGER)
if nConnect = SQL_SUCCESS Or nConnect = SQL_SUCCESS_WITH_INFO Then
nConnect = SQLAllocHandle(SQL_HANDLE_DBC,this.m_hEnv,@this.m_hDBC)
if nConnect = SQL_SUCCESS Or nConnect = SQL_SUCCESS_WITH_INFO Then
SQLSetConnectOption( this.m_hDBC,SQL_LOGIN_TIMEOUT,5 )
Dim shortResult As Short = 0
Dim szOutConnectString(1023) As SQLTCHAR
nConnect = SQLConnect(this.m_hDBC,_
StrPtr(DSN),_
SQL_NTS,_
StrPtr(User),_
SQL_NTS,_
StrPtr(Pass),_
SQL_NTS) 'no user prompt
if nConnect = SQL_SUCCESS Or nConnect = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
EndIf
EndIf
EndIf
If this.m_hDBC <> NULL Then
this.m_nReturn = SQLDisconnect(this.m_hDBC)
this.m_nReturn = SQLFreeHandle(SQL_HANDLE_DBC,this.m_hDBC)
EndIf
If this.m_hEnv <> NULL Then
this.m_nReturn = SQLFreeHandle(SQL_HANDLE_ENV,this.m_hEnv)
this.m_hDBC = NULL
this.m_hEnv = NULL
this.m_nReturn = SQL_ERROR
EndIf
Return FALSE
End Function
Sub ODBCConnection.Disconnect()
if this.m_hDBC <> NULL Then
this.m_nReturn = SQLDisconnect( this.m_hDBC )
this.m_hDBC = NULL
EndIf
End Sub
Function ODBCConnection.DBC() As HDBC
Return this.m_hDBC
End Function
Function ODBCConnection.MSSQLConnect(User As String,Pass As String,Host As String = "(local)",Trusted As Boolean = TRUE,Proto As EnumProtocols = protoNamedPipes) As Boolean
Dim tstr As String
Dim szTrusted As String
If Trusted = TRUE Then
szTrusted = "Yes"
Else
szTrusted = "No"
EndIf
tstr = "Driver={SQL Server};Server=" & Host & _
";Uid=" & User & _
";Pwd=" & Pass & _
";Trusted_Connection=" & szTrusted & _
";Network="
Select Case Proto
Case protoNamedPipes
tstr = tstr & "dbnmpntw;"
Case protoWinSock
tstr = tstr & "dbmssocn;"
Case protoIPX
tstr = tstr & "dbmsspxn;"
Case protoBanyan
tstr = tstr & "dbmsvinn;"
Case protoRPC
tstr = tstr & "dbmsrpcn;"
Case Else
tstr = tstr & "dbmssocn;"
End Select
Return this.Connect(tstr)
End Function
Function ODBCConnection.DB2Connect(DBPath As String) As Boolean
Dim tstr As String
tstr = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" & DBPath & ";"
Return this.Connect(tstr)
End Function
Function ODBCConnection.XLSConnect(XLSPath As String,DefDir As String = "") As Boolean
Dim tstr As String
tstr = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;" & _
"bq=" & DefDir & ";DefaultDir=" & XLSPath & ";"
Return this.Connect(tstr)
End Function
Function ODBCConnection.TXTConnect(TXTPath As String) As Boolean
Dim tstr As String
tstr = "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=" & TXTPath & ";Extensions=asc,csv,tab,txt;"
Return this.Connect(tstr)
End Function
Function ODBCConnection.FOXConnect(DBPath As String,User As String = "",Pass As String = "",SrcType As String = "DBF",Exclusive As Boolean = FALSE) As Boolean
Dim tstr As String
Dim bExcl As String
If Exclusive = TRUE Then
bExcl = "Yes"
Else
bExcl = "No"
EndIf
tstr = "Driver={Microsoft Visual Foxpro Driver};" & _
"Uid=" & User & _
";Pwd=" & Pass & _
";SourceDB=" & DBPath & _
";SourceType=" & SrcType & _
";Exclusive=" & bExcl & ";"
Return this.Connect(tstr)
End Function
Function ODBCConnection.MDBConnect(MDBPath As String,User As String = "",Pass As String = "",Exclusive As Boolean = FALSE) As Boolean
Dim tstr As String
Dim bExcl As String
If Exclusive = TRUE Then
bExcl = "Yes"
Else
bExcl = "No"
EndIf
tstr = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=" & MDBPath & _
";Uid=" & User & _
";Pwd=" & Pass & _
";Exclusive=" & bExcl & ";"
Return this.Connect(tstr)
End Function
Function ODBCConnection.MySQLConnect(User As String = "",Pass As String = "",Host As String = "localhost",Port As UInteger = 3306) As Boolean
Dim tstr As String
tstr = "Driver={MySQL ODBC 3.51 Driver};" & _
"Uid=" & User &_
";Pwd=" & Pass &_
";Server=" & Host &_
";Port=" & Port & ";"
Return this.Connect(tstr)
End Function
Function ODBCConnection.MySQLConnectDB(DB As String,User As String = "",Pass As String = "",Host As String = "localhost",Port As UInteger = 3306) As Boolean
Dim tstr As String
tstr = "Driver={MySQL ODBC 3.51 Driver};" & _
"Database=" & DB &_
";Uid=" & User &_
";Pwd=" & Pass &_
";Server=" & Host &_
";Port=" & Port & ";"
Return this.Connect(tstr)
End Function
'Statement***************************
Type ODBCStmt
m_hStmt As HSTMT
Public:
Declare Constructor(hDBCLink As HDBC)
Declare Destructor()
Declare Function IsValid() As Boolean
Declare Function GetColumnCount() As UShort
Declare Function GetChangedRowCount() As UInteger
Declare Function Query(strSQL As String) As Boolean
Declare Function Fetch() As Boolean
Declare Function FetchPrevious() As Boolean
Declare Function FetchNext() As Boolean
Declare Function FetchRow(nRow As UInteger,bAbsolute As Boolean = TRUE) As Boolean
Declare Function FetchFirst() As Boolean
Declare Function FetchLast() As Boolean
Declare Function GotoRow(nRow As UInteger) As Boolean
Declare Function Cancel() As Boolean
End Type
Constructor ODBCStmt(hDBCLink As HDBC)
Dim m_nReturn As SQLRETURN
m_nReturn = SQLAllocHandle(SQL_HANDLE_STMT,hDBCLink,@this.m_hStmt)
If m_nReturn = SQL_SUCCESS Or m_nReturn = SQL_SUCCESS_WITH_INFO Then
Else
this.m_hStmt = Cast(HSTMT,INVALID_HANDLE_VALUE)
EndIf
End Constructor
Destructor ODBCStmt()
If this.m_hStmt <> INVALID_HANDLE_VALUE Then
SQLFreeHandle(SQL_HANDLE_STMT,this.m_hStmt)
EndIf
End Destructor
Function ODBCStmt.IsValid() As Boolean
If this.m_hStmt = INVALID_HANDLE_VALUE Then
Return FALSE
Else
Return TRUE
EndIf
End Function
Function ODBCStmt.GetColumnCount() As UShort
Dim nCols As Short = 0
Dim nRet As SQLRETURN
nRet = SQLNumResultCols(this.m_hStmt,@nCols)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return nCols
Else
Return 0
EndIf
End Function
Function ODBCStmt.GetChangedRowCount() As UInteger
Dim nRows As UInteger = 0
Dim nRet As SQLRETURN
nRet = SQLRowCount(this.m_hStmt,@nRows)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return nRows
Else
Return 0
EndIf
End Function
Function ODBCStmt.Query(strSQL As String) As Boolean
Dim nRet As SQLRETURN
nRet = SQLExecDirect(this.m_hStmt,StrPtr(strSQL),SQL_NTS)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
End Function
Function ODBCStmt.Fetch() As Boolean
Dim nRet As SQLRETURN
nRet = SQLFetch(this.m_hStmt)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
End Function
Function ODBCStmt.FetchPrevious() As Boolean
Dim nRet As SQLRETURN
Dim stmt As HSTMT
stmt = this.m_hStmt
nRet = SQLFetchScroll(stmt,SQL_FETCH_PRIOR,0)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
End Function
Function ODBCStmt.FetchNext() As Boolean
Dim nRet As SQLRETURN
Dim stmt As HSTMT
stmt = this.m_hStmt
nRet = SQLFetchScroll(stmt,SQL_FETCH_NEXT,0)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
End Function
Function ODBCStmt.FetchRow(nRow As UInteger,bAbsolute As Boolean = TRUE) As Boolean
Dim nRet As SQLRETURN
nRet=SQLFetchScroll(this.m_hStmt,IIf(bAbsolute,SQL_FETCH_ABSOLUTE,SQL_FETCH_RELATIVE),nRow)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
End Function
Function ODBCStmt.FetchFirst() As Boolean
Dim nRet As SQLRETURN
Dim stmt As HSTMT
stmt = this.m_hStmt
nRet = SQLFetchScroll(stmt,SQL_FETCH_FIRST,0)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
End Function
Function ODBCStmt.FetchLast() As Boolean
Dim nRet As SQLRETURN
Dim stmt As HSTMT
stmt = this.m_hStmt
nRet = SQLFetchScroll(stmt,SQL_FETCH_LAST,0)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
End Function
Function ODBCStmt.GotoRow(nRow As UInteger) As Boolean
Dim nRet As SQLRETURN
nRet = SQLSetPos(this.m_hStmt,nRow,SQL_POSITION,SQL_LOCK_NO_CHANGE)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
End Function
Function ODBCStmt.Cancel() As Boolean
Dim nRet As SQLRETURN
nRet = SQLCancel(this.m_hStmt)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
End Function
'Record***************************
Type ODBCRecord
m_hStmt As HSTMT
Public:
Declare Constructor(hStmt As HSTMT)
Declare Destructor()
Declare Function GetColumnCount() As UShort
Declare Function BindColumn(Column As UShort,pBuffer As UByte ptr,BufferSize As UInteger,pReturnedBufferSize As UInteger ptr = NULL,nType As UShort = SQL_C_TCHAR) As Boolean
Declare Function GetColumnByName(Column As String) As UShort
Declare Function GetData(Column As UShort,pBuffer As UByte ptr,BufLen As Integer,pDataLen As UInteger ptr = NULL,nType As Integer = SQL_C_DEFAULT) As Boolean
Declare Function GetColumnType(Column As UShort) As Integer
Declare Function GetColumnSize(Column As UShort) As UInteger
Declare Function GetColumnScale(Column As UShort) As UInteger
Declare Function GetColumnName(Column As UShort) As String
Declare Function IsColumnNullable(Column As UShort) As Boolean
End Type
Constructor ODBCRecord(hStmt As HSTMT)
this.m_hStmt = hStmt
End Constructor
Destructor ODBCRecord()
End Destructor
Function ODBCRecord.GetColumnCount() As UShort
Dim nCols As Short = 0
Dim nRet As SQLRETURN
nRet = SQLNumResultCols(this.m_hStmt,@nCols)
If nRet = SQL_SUCCESS Or nRet = SQL_SUCCESS_WITH_INFO Then
Return nCols
Else
Return 0
EndIf
End Function
Function ODBCRecord.BindColumn(Column As UShort,pBuffer As UByte ptr,BufferSize As UInteger,pReturnedBufferSize As UInteger ptr = NULL,nType As UShort = SQL_C_CHAR) As Boolean
Dim pReturnedSize As UInteger = 0
Dim Ret As SQLRETURN
Ret = SQLBindCol(this.m_hStmt,Column,nType,pBuffer,BufferSize,@pReturnedSize)
If pReturnedBufferSize <> NULL Then
*pReturnedBufferSize=pReturnedSize
EndIf
If Ret = SQL_SUCCESS Or Ret = SQL_SUCCESS_WITH_INFO Then
Return TRUE
Else
Return FALSE
EndIf
End Function
Function ODBCRecord.GetColumnName(Column As UShort) As String
Dim nType As Integer = SQL_C_DEFAULT
Dim svColName As ZString * 256
Dim As Short swCol = 0,swType = 0,swScale = 0,swNull = 0
Dim pcbColDef As UInteger = 0
Dim Ret As SQLRETURN
Ret = SQLDescribeCol( this.m_hStmt,_' Statement handle
Column,_ ' ColumnNumber
@svColName,_ ' ColumnName
SizeOf(svColName),_ ' BufferLength
@swCol,_ ' NameLengthPtr
@swType,_ ' DataTypePtr
@pcbColDef,_ ' ColumnSizePtr
@swScale,_ ' DecimalDigitsPtr
@swNull ) ' NullablePtr
If Ret = SQL_SUCCESS Or Ret = SQL_SUCCESS_WITH_INFO Then
Return svColName
Else
Return ""
EndIf
End Function
Function ODBCRecord.GetColumnByName(Column As String) As UShort
Dim nCols As Short
Dim i As UShort
nCols = this.GetColumnCount()
For i = 1 To nCols+1
Dim ColName As ZString * 256
ColName = this.GetColumnName(i)
If StrCmp(@ColName,StrPtr(Column)) = 0 Then
Return i
EndIf
Next
Return 0
End Function
Function ODBCRecord.GetData(Column As UShort,pBuffer As UByte ptr,BufLen As Integer,pDataLen As UInteger ptr = NULL,nType As Integer = SQL_C_DEFAULT) As Boolean
Dim od As UInteger = 0
Dim nErr As Integer
nErr = SQLGetData(this.m_hStmt,Column,nType,pBuffer,BufLen,@od)
If nErr = SQL_SUCCESS Or nErr = SQL_SUCCESS_WITH_INFO Then
If pDataLen <> NULL Then
*pDataLen = od
EndIf
Return TRUE
Else
Return FALSE
EndIf
End Function
Function ODBCRecord.GetColumnType(Column As UShort) As Integer
Dim nType As Integer = SQL_C_DEFAULT
Dim svColName As ZString * 256
Dim As Short swCol = 0,swType = 0,swScale = 0,swNull = 0
Dim pcbColDef As UInteger = 0
Dim Ret As SQLRETURN
SQLDescribeCol( this.m_hStmt,_' Statement handle
Column,_ ' ColumnNumber
@svColName,_ ' ColumnName
SizeOf(svColName),_ ' BufferLength
@swCol,_ ' NameLengthPtr
@swType,_ ' DataTypePtr
@pcbColDef,_ ' ColumnSizePtr
@swScale,_ ' DecimalDigitsPtr
@swNull ) ' NullablePtr
nType = Cast(Integer,swType)
Return nType
End Function
Function ODBCRecord.GetColumnSize(Column As UShort) As UInteger
Dim nType As Integer = SQL_C_DEFAULT
Dim svColName As ZString * 256
Dim As Short swCol = 0,swType = 0,swScale = 0,swNull = 0
Dim pcbColDef As UInteger = 0
Dim Ret As SQLRETURN
SQLDescribeCol( this.m_hStmt,_' Statement handle
Column,_ ' ColumnNumber
@svColName,_ ' ColumnName
SizeOf(svColName),_ ' BufferLength
@swCol,_ ' NameLengthPtr
@swType,_ ' DataTypePtr
@pcbColDef,_ ' ColumnSizePtr
@swScale,_ ' DecimalDigitsPtr
@swNull ) ' NullablePtr
nType = Cast(Integer,swType)
Return pcbColDef
End Function
Function ODBCRecord.GetColumnScale(Column As UShort) As UInteger
Dim nType As Integer = SQL_C_DEFAULT
Dim svColName As ZString * 256
Dim As Short swCol = 0,swType = 0,swScale = 0,swNull = 0
Dim pcbColDef As UInteger = 0
Dim Ret As SQLRETURN
SQLDescribeCol( this.m_hStmt,_' Statement handle
Column,_ ' ColumnNumber
@svColName,_ ' ColumnName
SizeOf(svColName),_ ' BufferLength
@swCol,_ ' NameLengthPtr
@swType,_ ' DataTypePtr
@pcbColDef,_ ' ColumnSizePtr
@swScale,_ ' DecimalDigitsPtr
@swNull ) ' NullablePtr
Return swScale
End Function
Function ODBCRecord.IsColumnNullable(Column As UShort) As Boolean
Dim nType As Integer = SQL_C_DEFAULT
Dim svColName As ZString * 256
Dim As Short swCol = 0,swType = 0,swScale = 0,swNull = 0
Dim pcbColDef As UInteger = 0
Dim Ret As SQLRETURN
SQLDescribeCol( this.m_hStmt,_' Statement handle
Column,_ ' ColumnNumber
@svColName,_ ' ColumnName
SizeOf(svColName),_ ' BufferLength
@swCol,_ ' NameLengthPtr
@swType,_ ' DataTypePtr
@pcbColDef,_ ' ColumnSizePtr
@swScale,_ ' DecimalDigitsPtr
@swNull ) ' NullablePtr
If swNull = SQL_NULLABLE Then
Return TRUE
Else
Return FALSE
EndIf
End Function
End Namespace
Code: Select all
#Include Once "windows.bi"
#Include Once "crt.bi"
#Include Once "FBODBC.bi"
Dim DBLink as FBODBC.ODBCConnection ptr
Dim DBStmt as FBODBC.ODBCStmt ptr
Dim DBRecord as FBODBC.ODBCRecord ptr
DBLink = New FBODBC.ODBCConnection
If DBLink->MSSQLConnect("sa","123456","(local)") = FALSE then
?"Error connecting to mssql"
Endif
DBStmt = New FBODBC.ODBCStmt(DBLink->DBC()) 'create new statement object , passing connection handle to the constructor
'querying the database...
DBStmt->Query("USE NorthWind")
DBStmt->Query("Select * From [Customers]")
'new Record object linked to the statement
DBRecord = New FBODBC.ODBCRecord(DBStmt->m_hStmt)
Dim CustomerID as ZString * 5
DBRecord->BindColumn(1,@CustomerID,5) 'bind first column to a buffer
DBStmt->FetchFirst() 'go to first row set
?CustomerID
DBStmt->FetchNext() ' go to next row set
?CustomerID
DBStmt->FetchLast() 'go to last row set
?CustomerID
DBStmt->FetchPrevious() 'go to previous row set
?CustomerID
Dim CompanyName as ZString * 41
DBRecord->GetData(2,@CompanyName,41) 'Get data from the second column without bind it
?CompanyName
?DBStmt->GetChangedRowCount() 'get row count
Delete DBRecord
Delete DBStmt
Delete DBLink
Sleep