在表格中插入更多值 [英] Insert More Values in Table

查看:80
本文介绍了在表格中插入更多值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我想在表中插入一条记录.
其中,列多于20.
因此,现在我在C#方法中将所有值传递给不同的参数,并在存储过程中传递.

Dear Friends,

I want insert a record in a table.
Where as, the column are more then 20.
So now i am passing all the values a different parameter in C# method and passing in Stored Procedure.
Can any one guide or suggest any better option for the same.

推荐答案

目前没有更好的选择.

但是有几种选择各有各的优缺点,这取决于使用哪种应用程序要求.

我现在记得的其他选择是
1.将xml字符串传递给sp. XML字符串将包含所有值.当您进行批量插入时,这很有用. SQL Server具有内置功能来读取xml字符串,或者您可以使用xquery在sp中查询xml.
2.您可以使用SqlCommandBuilder插入命令来插入记录


但是,对于正常情况,我仍然认为,您现在的做法是最好的(无论您拥有多少列)

欢呼
There is no such better option what you are currently doing.

But there are several options each have their own pros and cons and it depends on the application requirement which one to use.

Other options, what I remember now are,
1. Pass a xml string to sp. XML string will contain all the values. This is useful when you are doing bulk insert. SQL Server has inbuilt function to read xml string or you can use xquery to query xml within sp.
2. You can use SqlCommandBuilder Insert command to insert the record


But still, I see for normal scenario, what your doing now is the best (whatever the number of columns you have)

cheers


这篇关于在表格中插入更多值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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