连接到 ODBC
动词:odbcConnect
可从以下位置获取: <Standard>
连接到 ODBC 数据库。
语法
odbcConnect --connectionstring(String) (DbConnection)=connection
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | Description |
|---|---|---|---|---|
| --connectionstring | 连接字符串 | 必需的 | 文本 | 用于连接到 ODBC 数据库的连接字符串。必须有先前配置的 ODBC 数据库。 |
输出
| 脚本 | 设计器 | AcceptedTypes | Description |
|---|---|---|---|
| connection | 连接 | 数据库连接 | 用于存储与 ODBC 数据库的连接的变量。 |
示例
此示例使用 ODBC 协议连接到数据库,然后使用断言条件命令验证连接是否成功。 如果连接为空,那么将显示消息“Could not connect to the Database!” 。
defVar --name dbConnection --type DbConnection
// Connect to the database via the connection string and store the data in the connection variable.
odbcConnect --connectionstring "Driver={Microsoft Access Driver (*.mdb)}; Dbq=C:\\file.mdb; Uid=Admin; Pwd=; \r\n" dbConnection=connection
// Check if the connection was successful
assert --message "Could not connect to the database!" --left "${dbConnection}" --operator "Is_Null" --negate