| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 451 人关注过本帖
标题:[求助]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
快速回复:[求助]VB+SQL Server 2000的数据库删除问题!
数据加载中...
 
   



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

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