在数据集中创建表并传递给数据库 [英] created table in dataset and passing to database

查看:69
本文介绍了在数据集中创建表并传递给数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经在数据集中创建了一个表,并且想要将一个新表传递给数据库.

我该怎么办?

感谢您的任何帮助

Hi everyone,

I have created a table in a dataset and I want pass a new table to the database.

How can I do this?

Thanks for any help

推荐答案

这仅适用于SQL Server2008.

This possible only with SQL Server 2008

Dim table As New DataTable("temp")
Dim col1 As New DataColumn("col1", System.Type.GetType("System.Int32"))
Dim col2 As New DataColumn("col2", System.Type.GetType("System.String"))
Dim col3 As New DataColumn("col3", System.Type.GetType("System.DateTime"))
table.Columns.Add(col1)
table.Columns.Add(col2)
table.Columns.Add(col3)


'Create a command object that calls the stored proc
Dim command As New SqlCommand("usp_AddRowsToMyTable", conn)
command.CommandType = CommandType.StoredProcedure

'Create a parameter using the new type
Dim param As SqlParameter = command.Parameters.Add("@MyTableParam", SqlDbType.Structured)
param.Value = table


好,请尝试以下操作:

http://social.msdn.microsoft.com/Forums/zh_cn/sqlxml/thread/091e34fe-44a8-42bf-b992-a09131246c61 [ http://bytes.com/topic/xml/answers/626359- how-pass-xml-file-stored-procedure [ ^ ]
Ok, try this:

http://social.msdn.microsoft.com/Forums/en/sqlxml/thread/091e34fe-44a8-42bf-b992-a09131246c61[^]

or

http://bytes.com/topic/xml/answers/626359-how-pass-xml-file-stored-procedure[^]


抱歉,我不需要创建过程
我在数据集中有一个新数据
作为
dtaset.table.add(newtable);

所以我要
更新此数据集以在数据库中创建新表
im sorry i not need to create a procedure
i have a new datatabel in dataset
as
dtaset.table.add(newtable);

so i want
upadte this dataset to create a new table in database


这篇关于在数据集中创建表并传递给数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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