oCn := FW_OpenAdoConnection( cdb )
if oCn == nil
? "failed"
return nil
endif
oCn := FW_OpenAdoConnection( cdb )
if oCn == nil
? "failed"
return nil
endif
MarioG wrote:Buen dia CrsitobaloCn := FW_OpenAdoConnection( cdb )
if oCn == nil
? "failed"
return nil
endif
nageswaragunupudi wrote:If you have installed sqlite odbc driver and want to use ODBC/ADO, FWH makes it EXTREMELY simple to use Sqlite3.
You do not have to know anything other than simple FWH ado functions, which we must be already using for other ADO databaes.
Here is a simple program:
- Code: Select all Expand view RUN
#include "fivewin.ch"
function Main()
local cdb := "testsqlite3.db"
local ocn, ors, cSql
oCn := FW_OpenAdoConnection( cdb )
if oCn == nil
? "failed"
return nil
endif
FW_AdoImportFromDBF( ocn, "c:\fwh\samples\customer.dbf" )
oRs := FW_OpenRecordSet( oCn, "customer" )
XBROWSER oRs FASTEDIT TITLE "SQLITE3 DATABASE TABLE"
oRs:Close()
ocn:close()
return nil
This program connects to the database if it exists and otherwise creates a new database and connects.
To use sqlite, you do not need to learn anything more than this and you can start working straight from the next minute.
-iinclude
-inc
-oOreganoGourmet
-run
source\OREGANOGOURMET.PRG
...
...
...
...
source\FunTools\WINTOOLS.C
source\FunTools\CRYPT.C
source\FunTools\BLOWFISH.C
Resource\OG_Harbour.rc
#
# $Id: hbmk.hbm 13358 2009-12-22 02:50:24Z vszakats $
#
E:/ToolsDeveloper/harbour-3.0.0/examples/gtwvw/gtwvw.hbc
# NOTE: Disabled until test code is cleaned/fixed.
#-w3 -es2
-w1 -es2
-lhbxpp
-lhbwin
-lhbct
-lace32
-lrddads
-lhbsqlit3
-lsqlite3
-lE:\ToolsDeveloper\tdolphin\lib\HARBOUR\MINGW32\libdolphin.a
-lE:\ToolsDeveloper\tdolphin\lib\mysql\libmysql.a
-lxhb
local cSQL := "CREATE TABLE IF NOT EXISTS " + cTabla + ;
"( 'ID' INTEGER UNIQUE," + ;
"'MGAPP' CHAR(15) NULL, " + ;
"'VERSION' CHAR(30) NULL, " + ;
"PRIMARY KEY('ID' AUTOINCREMENT) )"
local cInsert:= "INSERT INTO " +cTabla +" " + ;
"(ID,MGAPP,VERSION) " + ;
"VALUES (" + ;
"NULL," + ; // FW_ValToSQL( 0 ) // "," lo comentado son otras formas probadas
"'mgSQL3'," + ;
"'08.20 Build(0000)' )"
oConn:Execute( cInsert )
#include "fivewin.ch"
function Main()
local cdb := "testsqlite3.db"
local ocn, ors, cSql
FW_SetUnicode( .t. )
oCn := FW_OpenAdoConnection( cdb )
if oCn == nil
? "failed"
return nil
endif
if FW_AdoTableExists( "TEST1", oCn )
oCn:Execute( "DROP TABLE TEST1" )
endif
TEXT INTO cSql
CREATE TABLE TEST1 (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
MGAPP VARCHAR(15),
VERSION VARCHAR(30)
)
ENDTEXT
oCn:Execute( cSql )
cSql := "INSERT INTO TEST1 ( ID, MGAPP, VERSION ) VALUES ( NULL, 'mgSQL3', '08.20 Build(0000)' )"
oCn:Execute( cSql )
oRs := FW_OpenRecordSet( oCn, "select * from test1" )
xbrowser fwadostruct( ors )
XBROWSER oRs
oRs:Close()
ocn:close()
return nil
cSql := SQL INSERT INTO <table> ( fld1,fld2,... ) VALUES ( list of harbour variables )
local cSelect:= "SELECT Count(ID) FROM " +::cTablaSys + " WHERE APPNAME='"+cAppName+"'" // cAppName es el nombre del ejecutable que obviamente existe en la Tabla
::oRSDB:= FW_OpenRecordSet( ::oConDB, cSelect )
// Verifico asi:
if !FW_AdoQueryResult( cSelect, ::oRSDB:ActiveConnection ) == 0
? "ID", ::oRSDB:Fields( 'ID' ):Value
end
Error description: (DOS Error -2147352567) WINOLE/1007 No se encontró el elemento en la colección que corresponde al nombre o el ordinal solicitado. (0x800A0CC1): ADODB.Recordset
Args:
[ 1] = C ID
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 58 guests