Wiki Home

Sql Pics


Namespace: Wiki
* Makes the pics database, both sql and dbc (views)
CLEAR
on error xErrHlr( line(), message(1) )

xMkSql()
xMkDbc()

RETURN
*************************************************************
FUNCTION xMkSql()

* connect to the server
lhX = SQLCONNECT( 'mqis' )
lckErr( lhx, "connect" )

* wack the previous attempts:
nRet = SQLEXEC( lhX, 'drop database pics' )
? nRet

* Make an empty database
nRet = SQLEXEC( lhX, 'create database pics' )
lckErr( nRet, "create database pics" )

* Switch to the new database (not the same as USEing a vfp table)
nRet = SQLEXEC( lhX, 'use pics' )
lckErr( nRet, "use pics" )

* Make an empty table
TEXT to lcSql noshow
create table pics ( 
	pkPics smallint IDENTITY(1,1) PRIMARY KEY, 
	cDesc varchar(50),
	iPic image
)
ENDTEXT      

nRet = SQLEXEC( lhX, lcSql )
lckErr( nRet, "create table pics..." )

nRet = SQLDISCONNECT( lhX )
lckErr( nRet, "disconnect" )

return
*************************************************************
FUNCTION xMkDbc()

CREATE DATABASE pics
create connection ConMqis datasource Mqis 
create sql view rv_Pics remote connection ConMqis as ;
	select * from Pics

dbsetprop( "rv_Pics", "view", "SendUpdates", .t. )
dbsetprop( "rv_Pics", "view", "WhereType", 1 )

dbsetprop( "rv_Pics.pkPics", "field", "KeyField", .t. )

RETURN
      
*************************************************************************
function lCkErr( tcErr, tcDsc )
if !empty( tcDsc )
	? tcDsc, trans( tcErr )
endif
if tcErr < 0
	xErrHlr()
else
	return .t.
endif


*************************************************************************

function xErrHlr( tnLin, tcLin )
? tnLin, tcLin, MESSAGE()
cancel
----
CategoryCodeSamples