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数据
发布评论