如何通过用户定义表类型在C#中存储的参数Procedured [英] How to pass User Defined Table Type as Stored Procedured parameter in C#

查看:130
本文介绍了如何通过用户定义表类型在C#中存储的参数Procedured的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SQL Server 2008中,我们可以定义一个表类型,并用它作为存储过程参数。
但是,我怎么可以用它在该SP C#调用?换句话说,如何创建一个表或列表,并将其与SQL Server 2008?

In SQL Server 2008, we can define a table type and use it as Stored Procedures' parameters. But How can I use it in C# invocation of this SP? In other words, how to create a table or list and pass it into Stored Procedure in C# code with this new feature of SQL Server 2008?

推荐答案

您需要看这个例子在$ C $的CProject

SqlParameter param = cmd.Parameters.AddWithValue("@FileDetails", dt);

dt是一个DataTable,
而@fileDetails参数是SQL表类型:

where dt is a DataTable, and the @fileDetails parameter is a table type in SQL:

create type FileDetailsType as table
(
    FileName        varchar(50),
    CreatedDate        varchar(50),
    Size       decimal(18,0)
)

修改
这MSDN开发人员指南文章,也会有所帮助。

这篇关于如何通过用户定义表类型在C#中存储的参数Procedured的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆