如何使用数据集VB net 2010 / SQL更新multilape表 [英] How to update multilape tables using dataset VB net 2010/SQL
本文介绍了如何使用数据集VB net 2010 / SQL更新multilape表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,如何更新三个表不重复查询?
ds =新数据集
da =新MySqlDataAdapter( 更新youtube set views = views-1,clicks = clicks + 1,today_clicks = today_clicks + 1其中id = '& lvDisplay.Items( 0 )。SubItems( 1 )。文本& ',sqlcon)
da.Fill(ds, youtube)
ds = New DataSet
da = New MySqlDataAdapter( update users sets coins = coins +'& Label22。< span class =code-keyword> Text & 'where id ='& ListView2.Items( 0 )。SubItems( 0 )。文字& ',sqlcon)
da.Fill(ds, users)
ds = New DataSet
da = New MySqlDataAdapter( update web_stats set value = value + 1其中`module_id` ='youtube',sqlcon)
da.Fill( ds, web_stats)
解决方案
要更新数据,您需要调用 MySQLCommand。
ExecuteNonQuery [ ^ ]方法,而不是重新加载。
我以为你可以做它通过一个视图 - 但是,一个视图只能修改一个tablre,就像我在quic中看到的那样k trawl通过docco
我认为你不能避免多次插入,但是,我建议你将逻辑移到存储过程
SQL UPDATE命令用于一次更新一个且只有一个表 - 这是一个设计决定,目前无法更改...
hello, how to update three tables do not duplicating query?
ds = New DataSet
da = New MySqlDataAdapter("update youtube set views=views-1, clicks=clicks+1, today_clicks=today_clicks+1 where id ='" & lvDisplay.Items(0).SubItems(1).Text & "'", sqlcon)
da.Fill(ds, "youtube")
ds = New DataSet
da = New MySqlDataAdapter("update users set coins=coins+'" & Label22.Text & "' where id='" & ListView2.Items(0).SubItems(0).Text & "'", sqlcon)
da.Fill(ds, "users")
ds = New DataSet
da = New MySqlDataAdapter("update web_stats set value=value+1 Where `module_id` = 'youtube'", sqlcon)
da.Fill(ds, "web_stats")
解决方案
To update data, you need to call MySQLCommand.
ExecuteNonQuery[^] method, than load it again.
I was thinking you could do it through a view - but, a view can only modify one tablre as far as I can see in a quick trawl through the docco
I don't think you can avoid the multiple insert, but, I'd suggest you move the logic to a stored procedure
SQL UPDATE command designed to update one and only one table at one time - it's a design decision and can not be changed for now...
这篇关于如何使用数据集VB net 2010 / SQL更新multilape表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文