VS:DBDocAddConn: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
 
Line 24: Line 24:
dsn
dsn
DYNARRAY[] of CHAR
DYNARRAY[] of CHAR
 
Data source name.
</line>
</line>
<line>
<line>
userName
userName
DYNARRAY[] of CHAR
DYNARRAY[] of CHAR
 
Username. Pass empty string if not applicable.
</line>
</line>
<line>
<line>
password
password
DYNARRAY[] of CHAR
DYNARRAY[] of CHAR
 
Password. Pass empty string if not applicable.
</line>
</line>
</lineList>
</lineList>

Latest revision as of 13:35, 4 November 2015

.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