在连接的archr hoe中,从一个表中进行选择,然后插入其他tbale数据 [英] In connected archr hoe to select from one table then insert in other tbale data

查看:85
本文介绍了在连接的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数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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