连接到 SQL Server
动词:sqlServerConnect
可从以下位置获取: <Standard>
连接到 SQL Server 数据库。
语法
sqlServerConnect --connectionstring(String) (DbConnection)=connection
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | Description |
|---|---|---|---|---|
| --connectionstring | 连接字符串 | 必需的 | 文本 | 连接字符串,用于连接到 SQL Server 数据库。必须输入先前配置的 SQL Server 数据库。 |
输出
| 脚本 | 设计器 | AcceptedTypes | Description |
|---|---|---|---|
| connection | 连接 | 数据库连接 | 从数据库连接返回数据。 |
示例
此示例连接到 SQL Server 数据库,然后使用断言条件命令验证连接是否成功。 如果连接为空,那么将显示消息“Could not connect to the Database!” 。
defVar --name connection --type DbConnection
// Connect to the database via the connection string and store the connection data in the connection variable.
sqlServerConnect --connectionstring "Server=myServerAddress;Database=myDataBase;User Id=myUsername;\r\nPassword=myPassword;" connection=connection
// Check if the connection was successful
assert --message "Could not connect to the Database!" --left "${connection}" --operator "Is_Null" --negate