VS:DBDocAddConn

From Vectorworks Developer
Jump to: navigation, search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Add a database connection to the current document
FUNCTION DBDocAddConn(
dsn  :DYNARRAY[] OF CHAR;
userName  :DYNARRAY[] OF CHAR;
password  :DYNARRAY[] OF CHAR) : BOOLEAN;
def vs.DBDocAddConn(dsn, userName, password):
    return BOOLEAN

Parameters

dsn DYNARRAY[] of CHAR Data source name.
userName DYNARRAY[] of CHAR Username. Pass empty string if not applicable.
password DYNARRAY[] of CHAR Password. Pass empty string if not applicable.

Remarks

If a SQLite file does not exist at the specified location then a new database file will be created. { from Vectorworks 2014 }

Example

VectorScript

{ODBC connection needs DSN name}
PROCEDURE ConnectionSample;
VAR
	Tables : DYNARRAY [] OF CHAR;
	User : DYNARRAY [] OF CHAR;
	Pass : DYNARRAY [] OF CHAR;
	res : BOOLEAN;
BEGIN
	User := 'root';
	Pass := 'rootpass';
	res := DBDocAddConn( 'MyTestODBCDatabase', User, Pass );
	res := DBDocGetTables( 'MyTestODBCDatabase', Tables );
	AlrtDialog( concat( 'Result = ', res, ' ', Tables ) );
END;
RUN( ConnectionSample );

{ SQLite connection is available from VW 2014 }
{ SQLite connection needs [sqlite] prefix and full path to the database file }
PROCEDURE SQLiteConnTest;
VAR
        Tables : DYNARRAY [] OF CHAR;
	res : BOOLEAN;
BEGIN
	res := DBDocAddConn( '[sqlite]C:SQLiteSamplesMytestSQLite.sqlite', '', '' );
	res := DBDocGetTables( '[sqlite]C:SQLiteSamplesMytestSQLite.sqlite', Tables );
	AlrtDialog( Tables );
END;
RUN( SQLiteConnTest );

Python

#{ SQLite connection is available from VW 2014 }
#{ SQLite connection needs [sqlite] prefix and full path to the database file }
def SQLiteConnTest():
	res = vs.DBDocAddConn( '[sqlite]C:SQLiteSamplesMytestSQLite.sqlite', '', '' );
	res, Tables = vs.DBDocGetTables( '[sqlite]C:SQLiteSamplesMytestSQLite.sqlite' )
	vs.AlrtDialog( Tables );
SQLiteConnTest()

Version

Availability: from Vectorworks 2011
Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox