今天我们?继?续讲解 FastReport .NET的更?新功能:添加了连接到 MsSQL 存储过程的功能。
今天我们继续讲解 FastReport .NET的更新功能,在本次更新中,我们添加了连接到 MsSQL 存储过程的功能。这些存储过程是一组同时执行的指令。因此,存储过程允许您简化复杂的操作并将它们放入单个对象中。
以前,您只能通过数据库查询连接到它们。现在使用标准方案连接数据库表就足够了。
程序图标会有所不同。此外,如果过程有输入参数,在选择过程时则会出现一个带有参数的窗口。在此窗口中,您需要根据需求设置参数值。如果您使用默认值,则将表达式和值字段留空。
如果过程返回输出参数,那么它们将在创建连接后出现在“Report Parameters”中。只有当信息上传到数据源时,这些参数才会更新。
从代码调用过程:
// Create the MsSqlDataConnection objectvar connection = new MsSqlDataConnection();// Set the connection stringconnection.ConnectionString = @"Data Source=DESKTOP-43LGTAI;AttachDbFilename=; Initial Catalog=EmployeeCaseStudy;Integrated Security=True;Persist Security Info=False;User ID=;Password=";// Initialize all tablesconnection.CreateAllTables();// Set the connection nameconnection.Name = "NewConnection";// Create a Report Objectvar report = new Report();// Add the connection to a reportreport.Dictionary.Connections.Add(connection);// Enable connection displayconnection.Enabled = true;// Select a table and connect it to the reportforeach (TableDataSource table in connection.Tables){ if (table.Name == "sp_GetUser") { foreach (CommandParameter parameter in table.Parameters) if (parameter.Name == "@id") parameter.Value = 1; table.Enabled = true; }}
通过将它们与 ProcedureDataSource 进行比较,您可以在表的列表中找到过程。
现在,FastReport .NET 用户可以更快、更轻松地在多个 表中使用预先准备好的数据选择脚本。
关于从 表控件FastReport .NET v2023.1中添加了连接到 MsSQL 存储过程功能的介绍就到这里了,接下来将继续介绍其他更新模块,请持续关注哦~
FastReport技术
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!