Code: Select all
#include "fwce.ch"
Function Main()
local aRows, c, cNames := ""
CoInitializeEx()
aRows := Loadsdf()
for c := 1 To Len( aRows )
cNames += aRows[c][2]+ CRLF
next c
msginfo( cNames )
CoUninitialize()
return .t.
Function LoadSdf()
local cDatabase :="\My Documents\test.sdf"
local nError := 0, aRows := {}
if ConnectLocalDb( cdatabase ) != 0
oleDbError()
endif
if ExecuteSql( "CREATE TABLE CLIENTES (codigo INT, nombre NVARCHAR(30) )" ) != 0
oleDbError()
endif
ExecuteSQL("INSERT INTO CLIENTES (codigo,nombre) VALUES (1000,'Juan Garcia')")
ExecuteSQL("INSERT INTO CLIENTES (codigo,nombre) VALUES (1001,'Paco Ramirez')")
ExecuteSQL("INSERT INTO CLIENTES (codigo,nombre) VALUES (1002,'Luis Fernandez')")
ExecuteSQL("INSERT INTO CLIENTES (codigo,nombre) VALUES (1003,'Pedro Ponce')")
ExecuteSQL("INSERT INTO CLIENTES (codigo,nombre) VALUES (1004,'Jose Martinez')")
aRows := GetRowSet("SELECT * FROM CLIENTES", @nError)
return aRows
Function OleDbError()
local cError := Space(1024)
GetErrorMessage( @cError, Len( cError ) )
Msginfo( WidetoAnsi( cError ) )
return nil