从datagrid保存到sql表 [英] save from datagrid to sql table

查看:83
本文介绍了从datagrid保存到sql表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,所有vs.net 2005专业版

我想将行从datagrid保存到sql表

我的Winform应用程序中有一个datagrid,如

b> s.no testname testadd testno
1 Jam NYC 109

2 Dev DC 210

网格列名多行

当我在我的应用程序中点击保存时,我将一个外键值与datagrid行一起传递

在SQL端我将这些行保存在一个带有外键的表中= 12值如


ffkey testname testadd testno
12 jam NYC 109
12 Dev DC 210



如何从Win表单端实现这一点和SQL服务器端

任何帮助非常感谢

提前感谢
DAM


解决方案

您好Maddy06,有多种选项可用于将结果从数据网格保存到服务器。最重要的是,您需要选择最适合您的数据访问技术。对于上面提到的用例,您可以直接编写SQL语句
,并在单击SAVE按钮时通过ADO.Net提供程序执行它们。有关如何在以下位置使用ADO.Net的更多信息:
http://msdn.microsoft.com/en-us/library/aa302325.aspx


还有其他技术,如实体框架,LINQ to SQL和WCF数据服务,您可以根据应用程序的需要选择这些技术。


Hi all                                                                                                                        vs.net 2005 professional edition

I want to save the rows from datagrid to sql table

I have a datagrid in my Winform application like

                                                          s.no         testname  testadd testno 
                                                               1           Jam        NYC       109

                                                                2            Dev        DC          210

column names of the grid with multiple rows

when i hit save in my app  ,I pass a foreign key value along with datagrid rows

In the sql side I to save  this rows in a table  with the foreign key =12 value like  


                                                          ffkey     testname   testadd     testno
                                                            12           jam               NYC      109
                                                              12          Dev              DC           210



How to achieve this  from Win forms side and SQL server side

Any help is greatly appreciated

Thanks in advance
DAM


解决方案

Hi Maddy06, There are mutiple options available to save the results from a data grid to a server. Most importantly, you need to pick a data acess technology that works best for you. For the use case you mention above, you can directly write your SQL statements and execute them via an ADO.Net provider when the SAVE button is clicked. More information on how to use ADO.Net at: http://msdn.microsoft.com/en-us/library/aa302325.aspx

There are other technologies like Entity Framework, LINQ to SQL and WCF Data Services, which you could pick up from based on your application needs.


这篇关于从datagrid保存到sql表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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