Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Adam Walan
  Where is Adam Walan?
 Chicago
 Illinois - United States
 Adam Walan
 To: Stefanus Eddy
  Where is Stefanus Eddy?
 Surabaya
 Indonesia
 Stefanus Eddy
 Tags
Subject: RE: bests practise connect to MSSQL
Thread ID: 268533 Message ID: 268657 # Views: 37 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Tuesday, July 13, 2010 7:48:48 PM         
   


> dear all expert,
>
> as i said in my message subject: bests practise connect to MSSQL, i plan to use MSSQL server as backend DB and create connection from VFP to MSSQL is succes, and my question is: leave this connection always open and i can used it in all my form or open and close this connection when i need it in form and close this connection when i release form. please guide me
>
>
>
>
> regards,
>
> eddy

I also use SPT and I prefer to use connection strings (you can find connection string to many sql servers on www.connectionstrings.com)

Here is what I'm using for Ms SQL: (if someone is connecting from internet I recommend to change default 1433 port to something else...)

PUBLIC db
lc_conn_string="DRIVER=SQL Server;SERVER=192.168.0.10;Network=dbmssocn;Port=1433;UID=SA;PWD=mypass"+;
";APP=my_appName;WSID=MY_COMP_NAME;DATABASE=my_DB_NAME;LANGUAGE=english;Regional=Yes;Address=192.168.0.10,1433"

db=SQLSTRINGCONNECT(lc_conn_string)
IF db>0
*OK
messgaebox("Connected")
ELSE
RETURN .F.
ENDIF

Then you can use this public variable "db" everywhere:
instr1="SELECT * FROM table1 WHERE userName='adam'"
*Messagebox(instr1)
ret1=SQLExec(m.db,m.instr1,'cur_user')
If m.ret1<0
*SQLERROR occured
Else
endif


Adam

ENTIRE THREAD

bests practise connect to MSSQL Posted by Stefanus Eddy @ 7/13/2010 4:58:06 AM
RE: bests practise connect to MSSQL Posted by Samir H. @ 7/13/2010 5:34:36 AM
RE: bests practise connect to MSSQL Posted by Erik Gomez @ 7/13/2010 8:25:59 AM
RE: bests practise connect to MSSQL Posted by Stefanus Eddy @ 7/13/2010 10:25:34 AM
RE: bests practise connect to MSSQL Posted by Adam Walan @ 7/13/2010 7:48:48 PM
RE: bests practise connect to MSSQL Posted by Stefanus Eddy @ 7/14/2010 2:10:30 PM