Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create sql database tables and indexes with vfp
Message
De
22/06/2007 07:50:55
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
21/06/2007 20:45:02
Hee Lim Wang
Fantasy Software Enterprise
Malaisie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01234898
Message ID:
01234941
Vues:
32
>Hi !
>can any one tell me how to create sql database tables and indexs
>with vfp programmatically into the sql server or msde ?

Here is a sample:
Local lnHandle, lcDatabaseName
lcDatabaseName = "myTestData"
lnHandle=SQLStringConnect('DRIVER=SQL Server;SERVER=.;Trusted_connection=Yes')
If SQLExec(lnHandle, "create database "+lcDatabaseName) < 0
  Do errHand
  Return
Endif
mySQLExec(lnHandle, "use "+lcDatabaseName)
mySQLExec(lnHandle, ;
  "create table myTable"+;
  " (myID int not null, myDate datetime not null)")
SQLPrepare(lnHandle, "insert into myTable (myID, myDate) values (?m.ix,?m.myDate)")

For ix=1 to 10
  m.myDate = Date()+m.ix
  SQLExec(lnHandle)
Endfor
mySQLExec(lnHandle, "select * from myTable","myCheck")
SQLDisconnect(lnHandle)
Browse

Function mySQLExec
Lparameters tnHandle, tcSQL, tcCursorName
tcCursorName = iif(empty(tcCursorName),'',tcCursorName)
If SQLExec(tnHandle,tcSQL,tcCursorName) < 0
  Do errHand with tcSQL
Endif

Function errHand
Lparameters tcSQL
lcError=tcSQL+chr(13)
Aerror(arrCheck)
For ix=1 to 7
  lcError = lcError+trans( arrCheck [ix])+ chr(13)
Endfor
Messagebox(lcError,0,'Error def.')
PS: You might also do this:
text to m.lcSQL noshow
--SQL commands here as you would write in SQL analyzer
endtext

SQLexec(m.lnHandle,m.lcSQL)

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform