在sql和vb6中更新语句 [英] update statement in sql and vb6
本文介绍了在sql和vb6中更新语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好那里
我在sql中有以下语句如果我运行它在sql查询anylizer它的工作正常。我想在我的vb6项目中执行它。意味着我如何在vb6中执行以下语句。
声明 < span class =code-sdkkeyword> @ txnno int
set < span class =code-sdkkeyword> @ txnno = 1
更新 toll_veh_out SET @ txnno = txn_no = @ txnno + 1 其中 shift_date = ' < span class =code-string> 2012-11-01' 和 out_plaza_id = 1 和 booth_no = 13
提前谢谢
解决方案
这是浪费时间。 SQL语句结束后,您的变量就会丢失,因此设置它没有任何价值。您可以从代码中删除它。只需设置txn_no = txn_no + 1.
此外,VB6是垃圾,没有人使用它,它已经过时了十年。你在浪费时间学习它。
试试这个..
< span class =code-keyword> Dim CN As 新 ADODB.Connection
Dim cmd As 新 ADODB。命令
''' 连接数据库连接
CN。打开 连接字符串
使用 cmd
.ActiveConnection = CN ' 设置连接对象
.CommandType = adCmdStoredProc ' 设置存储过程命令类型
.CommandText = 跨度> UpdateTable ' 设置存储过程的名称
。执行' 在存储过程中执行sql语句
结束 使用
设置 cmd = Nothing
CN.Close
设置 CN = 没有跨度>
hello there
I have a following statement in sql if i run it int sql query anylizer its work properly. I want to execute it in my vb6 project. Means how can i execute following statement in vb6.
declare @txnno int
set @txnno = 1
UPDATE toll_veh_out SET @txnno = txn_no = @txnno + 1 where shift_date = '2012-11-01' and out_plaza_id = 1 and booth_no = 13
thank you in advance
解决方案
This is a waste of time. Your variable is lost as soon a the SQL statement ends, so there''s no value in setting it. You can remove it from your code. Just do set txn_no = txn_no + 1.
Also, VB6 is rubbish, no-one uses it, it''s been obsolete for a decade. You''re wasting your time learning it.
Try this..
Dim CN As New ADODB.Connection Dim cmd As New ADODB.Command ''' Connect your database connection CN.Open "Connection String" With cmd .ActiveConnection = CN ' set the connection object .CommandType = adCmdStoredProc ' set the stored procedure command type .CommandText = "UpdateTable" ' set the name of stored procedure .Execute ' execute the sql statement in stored procedure End With Set cmd = Nothing CN.Close Set CN = Nothing
这篇关于在sql和vb6中更新语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文