如何使用datagridview插入,更新数据到sql server中的表?(How to insert,update data to table in sql server using datagridview)

   IT问题网   2021-01-23 00:00:00

问 题

大家好。

i在sql server 2008中有1个表(salesdetail)

在这个表中,我有3个字段(代码,项目代码,数量)

在vb.net中,我创建一个表单并在该表单上删除datagridview

i还在datagridview上设置5列(itemcode,iteamname,qty,price,total)

i用户sql语句,如下所示("select itemcode,itemanem,price from item where itemcode'''amp; txtitemcode.textamp;"''""")

i使用此查询将项目信息显示到我的gridview。

当我在gridview上输入3项时,我想将gridview中的所有项目保存到我的表格(销售订单)

注意

i只想保存代码,物品代码,数量到我的salesdetail,商品名称,价格,总使用量仅供显示。



请帮我如何将数据从gridview保存到我的桌子?



最好的问候,

tony

解决方案

你可以使用sqldataadapter[ ^ ]以反映datagridview(或实际上在数据表中)对数据库的更改。



例如,请参阅: http://msdn.microsoft.com/en -us / library / fbk67b6z.aspx[ ^ ]



另外注意:不要在sql语句中连接文字("select itemcode,itemanem,price from item where itemcode = ''amp; txtitemcode.textamp; "''"")。而是使用参数。更多信息: sqlparameter[ ^ ]

标签:如何使用插入更新数据中的



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

如何从GetDate获取时间()(How to get only Time from GetDate())

problem how to get only time from getdate(). format is hh ...

使用Windows服务时出现问题(A problem in working with windows service)

problem hi, i have created a windows service ...

Windows窗体应用程序中跟踪栏的代码(code for trackbar in windows form application)

problem hi, there is a trackbar in my window ...

Prism女士和域名服务银光(Ms Prism and Domain services with silverlight)

problem hi, how can i work with microsoft pri ...

使用Python访问我的.dll文件(Access my .dll file using Python)

problem i am currently planning to access my mfc dialog b ...

从另一个Windows服务调用Windows服务(Call windows service from another windows service)

problem is it possible to call windows service from anoth ...

创建会计程序(creating accounting program)

problem hi all, can any one guide me how to creat acco ...

c sharp regex替换任何单词的第一个或最后一个字符(c sharp regex replace first or last character of any word)

problem want to remove first and last charact ...

用于检查字符串数组是否为空的代码(Code for checking whether string array is empty or not)

problem hi, please send me the code for checking whether ...

消息在try catch块中不起作用(Message is not working in try catch block)

problem showing a modal dialog box or form wh ...

循环如何从开始日期算起5天(How loop to count for 5 days from the start date)

problem hi i have a starting date, now i nee ...

如何绑定diffirent windows窗体中使用的相同用户控件组合框的两个数据源(how to bind two data sources for same user control combo box used in diffirent windows forms)

problem lt;pre lang="c#"gt;lt;/pregt; i want to bind two ...

是他们的任何querybuilder工具(Is Their any querybuilder tool)

problem i want to know that is dere any gui q ...

我希望从gridview获得一个链接来搜索报告页面(i want to have a link from a gridview that will search a report page)

problem can someone help me i want to search fromgridview ...

存储文本框值时无法获得正确的输出(not getting correct output when storing textbox values)

problem i keep getting the output in messagebox as ''0'' ...

如何在asp.net中调用客户端的服务器端功能?(How to call server side function in client side in asp.net)

problem how to call server side function in client side i ...

将Excel数据导入并更新到sql中(Import and Update Excel data into sql)

problem hi, am working on a project which import data int ...

如何在asp中使用我的sql(How to use my sql in asp)

problem hi sir/madam, in our application of asp,we have ...

如何制作wpf鼠标事件?(How can made wpf mouse event )

problem how can made wpf mouse event see more: c# please ...

如何在包含三个用于用户输入的asp.net服务器控件的表中动态添加行(how to add rows dynamically in the table containing three asp.net server controls for user input)

problem hi a table having 5 rows and 3 columns, each ro ...