标题:[求助]VB+SQL Server 2000的数据库删除问题!
取消只看楼主
p5588
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-11-10
 问题点数:0 回复次数:1 
[求助]VB+SQL Server 2000的数据库删除问题!

'//连接SQL 模块代码:

Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public addFlag As Boolean

Public Function OpenCn(str_srv As String, str_id As String, str_pwd As String, str_db As String) As Boolean
Dim mag As String
On Error GoTo strerrmag
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Driver={sql server};server=" & Trim(str_srv) & ";uid=" & Trim(str_id) & ";pwd=" & Trim(str_pwd) & ";database=" & Trim(str_db) & ""
conn.ConnectionTimeout = 5
conn.Open
addFlag = True
Exit Function
strerrmag:
mag = "can not connect to sql server !"
Call MsgBox(mag, vbOKOnly + 16, "error")
addFlag = False
Exit Function
End Function


Public Sub cloCn()
On Error Resume Next
If conn.State <> adStateClosed Then conn.Close
Set conn = Nothing
End Sub

Public Sub cloRs()
On Error Resume Next
If rs.State <> adStateClosed Then rs.Clone
Set rs = Nothing
End Sub
//----------------------------------------------

在执行数据插入、更新都没有出错,但执行删除操作时出错(如图)!


'//
Private Sub Cmd_del_Click()
Call OpenCn(Nsqlser.Text, txt_name.Text, txt_pwd.Text, txt_db.Text)
conn.Execute "delete * from my_admin" '//(提示这里出错!)
'//conn.Execute "update my_admin set admin='admin' where id=10"
End Sub

请问各位大侠怎么解决这个问题?

搜索更多相关主题的帖子: SQL 数据库 Server 删除 
2006-11-10 10:13
p5588
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-11-10
得分:0 
已经解决了,VB删除是"Delete from "而非"delete * from "?
2006-11-10 10:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-101940-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.063489 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved