当前位置:网站首页>C # problem of updating data: dynamic SQL generation is not supported for multiple base tables
C # problem of updating data: dynamic SQL generation is not supported for multiple base tables
2022-04-23 21:46:00 【CSDN Q & A】
public static bool updateData(DataSet ds, DataTable dt, string strsql) { bool flag = false; SqlCommand sqlcmd = new SqlCommand(strsql, ConnectionPool.getPool().getConnection()); using (SqlDataAdapter da = new SqlDataAdapter(sqlcmd)) { SqlCommandBuilder builder = new SqlCommandBuilder(da); try { da.UpdateCommand = builder.GetUpdateCommand(); int ii = da.Update(ds, dt.TableName); flag = true; } catch (SqlException ea) { flag = false; throw new Exception(ea.Message); } } return flag; }
-- Save button code
private void toolStripButton1_Click(object sender, EventArgs e)
{
gridView2.CloseEditor();
gridView2.UpdateCurrentRow();
updateData(dsBuJian, dtBuJian, "SELECT ID,Des14 FROM TEST1 where 1=2")
updateData(dsBuJian, dtBuJian, "SELECT Matid,OtherDes1 FROM TEST2 where 1=2")
}
Unable to update multiple tables , So I wrote two lists Table update , When executing the above statement , Only the first... Can be executed successfully updateData.
gridView2 The data displayed in the table are two related tables ,SQL as follows ,
SQL=''select a.ID,a.Des14,b.OtherDes1,b.Matid
from TEST1 a with(nolock)
join TEST2 b with(nolock) on a.matid=b.matid"
版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204131512511052.html
边栏推荐
- 上海确保疫情保供生活物资质量和食品安全
- Sklearn function: Train_ Test_ Split (split training set and test set)
- Tensorflow1. X and 2 How does x read those parameters saved in CKPT
- ROS learning notes - tutorial on the use of ROS
- C, print the source program of beautiful bell triangle
- [leetcode refers to offer 10 - I. Fibonacci sequence (simple)]
- Question brushing plan -- backtracking method (I)
- 小米手机全球已舍弃“MI”品牌,全面改用“xiaomi”全称品牌
- Xiaomi mobile phone has abandoned the "Mi" brand all over the world and switched to the full name brand of "Xiaomi"
- DW basic tutorial (I)
猜你喜欢
一文解决浏览器跨域问题
flomo软件推荐
Ali has another "against the sky" container framework! This kubernetes advanced manual is too complete
Opencv application -- jigsaw puzzle
Chrome 94 introduces the controversial idle detection API, which apple and Mozilla oppose
thinkphp5+数据大屏展示效果
[leetcode refers to offer 47. Maximum value of gift (medium)]
Question brushing plan - depth first search (II)
Problem brushing plan -- dynamic programming (III)
随机推荐
Oracle intercepts special characters
Display, move, rotate
Error message: b04access.00f eve'. Read of address 000001B4
Valueerror: invalid literal for int() with base 10 conversion error related to data type
setInterval、setTimeout、requestAnimationFrame
Cancel the default open project setting of idea
[leetcode refers to offer 32 - III. print binary tree III from top to bottom (medium)]
NVM introduction, NVM download, installation and use (node version management)
上海确保疫情保供生活物资质量和食品安全
管道和xargs
亚马逊和Epic将入驻,微软应用商城向第三方开放
MySQL 回表
韩国或将禁止苹果和谷歌向开发者抽佣 创全球首例
Two Stage Detection
ROS learning notes - tutorial on the use of ROS
ros功能包内自定义消息引用失败
[leetcode sword finger offer 10 - II. Frog jumping steps (simple)]
[※ leetcode refers to offer 32 - II. Print binary tree II from top to bottom (simple)]
Yolov5 NMS source code understanding
CVPR2022 | 基于知识蒸馏的高效预训练