activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

开发者活动

上次更新日期 2026年2月27日

最佳实践

将存储过程与 Oracle 参考光标一起使用

在 Oracle 中使用存储过程时,请确保“参考光标”已与 Oracle.ManagedDataAccess.Types.OracleRefCursor 变量正确绑定。

为此,您需要确保参数的数量及其类型与“运行查询”活动的“参数”属性中的设置相符。



您可以使用“调用代码”活动获取光标的内容,也可以将其作为输入参数传递给另一个数据库查询。以下是用于将光标内容转换为数据表的调用代码示例:

Oracle.ManagedDataAccess.Client.OracleDataReader reader2 = myRefCursor.GetDataReader();
                dt = new DataTable();
                dt.Load(reader2);Oracle.ManagedDataAccess.Client.OracleDataReader reader2 = myRefCursor.GetDataReader();
                dt = new DataTable();
                dt.Load(reader2);
您应该在用完光标后将其丢弃。您可以使用“调用代码”活动 (myRefCursor.Dispose),使用“系统”活动包中的“调用方法”活动或通过您运行的 SQL 命令来执行此操作。

Connection strings for different database systems

This guide provides sample connection strings for the Connect to Database activity, enabling you to connect to various databases using native and ODBC drivers. It includes examples for Microsoft SQL Server and popular ODBC drivers such as MySQL, Oracle, and PostgreSQL. Follow best practices to ensure secure and efficient database connectivity.

Microsoft SQL Server

Common connection string formats for Microsoft SQL Server when using the Microsoft.Data.SqlClient

1. Using SQL Server authentication:

Data Source=SERVER_NAME;Initial Catalog=DATABASE_NAME;User ID=USERNAME;Password=PASSWORD;

2. With a specific port:

Data Source=SERVER_NAME,PORT_NUMBER;Initial Catalog=DATABASE_NAME;User ID=USERNAME;Password=PASSWORD;

3. Using the ODBC driver

Driver={ODBC Driver 18 for SQL Server};Server=SERVER_NAME;Database=DATABASE_NAME;Uid=USERNAME;Pwd=PASSWORD;Encrypt=yes;TrustServerCertificate=no;

You can learn more about it via the official Microsoft documentation page here.

Excel file

Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=C:\full\path\to\the\sampleFile.xlsx;

Oracle Managed Data Access

Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XEPDB1)));User II=system;Password=your_password;

You can learn more about it via the official Microsoft documentation page here.

MySql ODBC 8.3 Unicode 驱动程序

Driver={MySQL ODBC 8.3 Unicode Driver};Server=SERVER_NAME;Database=DATABASE_NAME;User=USERNAME;Password=PASSWORD;Option=3;

You can learn more about it viat the official MySQL documentation page here.

MySql ODBC 8.3 ANSI 驱动程序

Driver={MySQL ODBC 8.3 ANSI Driver};Server=SERVER_NAME;Database=DATABASE_NAME;User=USERNAME;Password=PASSWORD;Option=3;

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2026 UiPath。保留所有权利。