在连接的archr hoe中,从一个表中进行选择,然后插入其他tbale数据

编程入门 行业动态 更新时间:2024-10-24 04:44:08
本文介绍了在连接的archr hoe中,从一个表中进行选择,然后插入其他tbale数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

string strRegi =插入Regi_RecordsTB(App_No,Course)值(+ int.Parse(txtAppl_no.Text)+,+ cboxcourse.Text +')从new_crs_editorTB选择(课程);不选择从其他tbale如何? 我尝试过: string strRegi =插入Regi_RecordsTB(App_No,Course)值(+ int.Parse(txtAppl_no.Text)+,+ cboxcourse.Text +')从new_crs_editorTB中选择(课程);不从其他tbale中选择如何?

string strRegi = "insert into Regi_RecordsTB(App_No,Course) values(" + int.Parse(txtAppl_no.Text) + ",'"+ cboxcourse.Text +"') select(course) from new_crs_editorTB";not select from other tbale how? What I have tried: string strRegi = "insert into Regi_RecordsTB(App_No,Course) values(" + int.Parse(txtAppl_no.Text) + ",'"+ cboxcourse.Text +"') select(course) from new_crs_editorTB";not select from other tbale how?

推荐答案

如果要发出多个命令,则需要用分号终止它们。此外,INSERT将生成一个结果集,尽管其中一行为零,因此您的调用代码需要考虑到这一点,但您可以使用SET NOCOUNT ON忽略空数据集。接下来如果你想获得你刚刚插入的行的ID,请使用SELECT SCOPE_IDENTITY()。 使用那些你应该能做的事情你在做什么。还要使用参数化查询,因为您的代码容易受到SQL注入攻击。 If you want to issue multiple commands you need to terminate them with a semi-colon. Also the INSERT will generate a result set, albeit one with zero rows, so your calling code will need to take that into account, but you can ignore the empty dataset by using SET NOCOUNT ON. Next if you want to get the ID for the row you've just insert into use SELECT SCOPE_IDENTITY(). Using those things you should be able to get to do what you're doing. Also look to use parameterised queries as your code is liable to sql injection attacks.

更多推荐

在连接的archr hoe中,从一个表中进行选择,然后插入其他tbale数据

本文发布于:2023-10-26 09:45:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1529791.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   archr   hoe   tbale

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!