Saturday, June 25, 2011

Sql server connection with Foxpro 9.0

LOCAL hConn
STORE SPACE(40) TO strname
STORE SPACE(1000) TO strstring
hConn = SQLStringConnect("Dsn=Sql Server;trusted_connection=Yes;wsid=MachineName-PC;database=Hackensack")
hConn = SQLConnect("Sql Server", "falseuser", "")
IF (hConn < 0)
LOCAL ARRAY laError[1]
AERROR(laError)
MESSAGEBOX( ;
laError[2], ;
"Error " + TRANSFORM(laError[5]))
*laError[5] --show the what error happen
ELSE
CLEAR

@10,10 say "Enter the Name :" Get strname
read
*--sql insert string
strstring = "insert into Table1 (Name) values ('"+RTRIM(strname) +"')"

@ 17, 2 SAY [String : ] + TRIM(strstring)
SQLEXEC(hConn ,strstring )
MESSAGEBOX("Add Successfully")

SQLEXEC(hConn , 'SELECT * FROM Table1', 'Table1')
BROWSE
SQLDISCONNECT(hConn )


ENDIF

No comments: