SQLDatabaseCreate - cDbUpdateFunctionLibrary
To create a new Microsoft SQL Server database (not table!)
Type: Function
Parameters: String sTableName
Parameter |
Description |
sDriverID |
MSSQLDRV_ID |
sDatabase |
The name of the database to be created. |
bUpdateConnectionString |
Pass True to update the current Connection string Database setting of the SQLConnection. |
bPermanantly |
Pass True to update the SQLConnection ini file with the newly created database. |
Syntax
Function SqlDatabaseCreate String sDriverID String sDatabase ;
Boolean bUpdateConnectionString Boolean bPermanantly Returns Boolean
Call: |
Get SqlDatabaseCreate MSSQLDRV_ID "OrderEntry" True True to bOK |
Description
Use it to create a new SQL database. Currently only supported for MS-SQL Server, as it is the only SQL database that have such a feature. It checks if the SQL database exists; else it will create it. You will probably also like to pass pbUpdateConnectionString=True, and bPermanently=True. If you also (highly suggested) specified "Master" as the SQL database with the SQLConnection Manager program when creating a connection here's what will happen;
After the database is created the database, the SQL connection string's "database" parameter will be changed from "Master" to the value of the "sDatabase" parameter passed to this function. This will be done both in the running program and on disk for the SQLConnection.ini file, thus making the change permanent, aka the next time your program is started the database will point to the newly created SQL database.
Example
Procedure OnPreUpdate
Boolean bOK
Set psCollation to "Latin1_General_CS_AS"
Get SqlDatabaseCreate MSSQLDRV_ID "OrderEntry" True True to bOK
If (bOK = False) Begin
Send Info_Box "Nope, that didn't work. Program will now exit."
Send Exit_Application
End_Procedure
End_Procedure