| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 495 人关注过本帖
标题:[求助]vb+sql开发遇到的问题
取消只看楼主 加入收藏
laiwin
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-11-6
收藏
 问题点数:0 回复次数:3 
[求助]vb+sql开发遇到的问题
我现在做着一个"学生信息管理系统" 其中有一段公用模块代码如下:
Public Function executesql(ByVal sql As String, msgstring As String) As adodb.Recordset
Dim cnn As adodb.connection
Dim rst As adodb.Recordset
Dim stokens() As String
On Error GoTo executesql_error
stokens = Split(sql)
Set cnn = New adodb.connection
cnn.open connectstring
If InStr("insert,delete,update", UCase$(stoken(0))) Then
cnn.execute sql
msgstring = stokens(0) & "query successful"
Else
Set rst = New adodb.Recordset
rst.open (sql), cnn, adopenkeyset, adlockoptimistic
Set executesql = rst
msgstring = "查询到"& rst.recordcount & "条记录"
End If
executesql_exit:
Set rst = Nothing
Set cnn = Nothing
End Function
executesql_error:
msgstring = "查询错误:" & Err.Description
Resume executesql_exit
End Function

调试时老是说:"用户未自定义对象(代码中的红色段)",接着下面程序还用到的变量executesql也就还说:"用户未自定义对象",请大家帮忙!!!
搜索更多相关主题的帖子: sql 开发 
2007-11-06 18:57
laiwin
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-11-6
收藏
得分:0 
具体要怎么做啊???讲讲办法嘛!!!
2007-11-06 21:23
laiwin
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-11-6
收藏
得分:0 
具体写写啊大哥们,用代码引用???怎么写???还是用ADO控件连接引用ADO库啊???
2007-11-06 22:01
laiwin
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-11-6
收藏
得分:0 

Public Function executesql(ByVal sql As String, msgstring As String) As adodb.Recordset
Dim cnn As adodb.connection
Dim rst As adodb.Recordset
Dim stokens() As String
On Error GoTo executesql_error
stokens = Split(sql)
Set cnn = New adodb.connection
cnn.open connectstring
If InStr("insert,delete,update", UCase$(stoken(0))) Then
cnn.execute sql
msgstring = stokens(0) & "query successful"
Else
Set rst = New adodb.Recordset
rst.open (sql), cnn, adopenkeyset, adlockoptimistic
Set executesql = rst
msgstring = "查询到" & rst.recordcount & "条记录"
End If
executesql_exit:
Set rst = Nothing
Set cnn = Nothing
End Function
executesql_error:
msgstring = "查询错误:" & Err.Description
Resume executesql_exit
End Function
Public Function connectstring() As String
connection = "provider=sqloledb;uid=sa;pwd=sayu;database=xsgl"
End Function
Sub main()
Dim flogin As New frmlogin
flogin.Show vbModal
If Not flogin.ok Then
End
End If
Unload flogin
Set fmainform = New frmmain
fmainform.Show
End Sub

Public Function testtxt(txt As String) As Boolean
testtxt = False
Else
testtxt = True
End If
End Function


Public Function connectstring() As String
connection = "provider=sqloledb;uid=sa;pwd=sayu;database=xsgl"
End Function

这段是引用库了吗???

2007-11-06 22:09
快速回复:[求助]vb+sql开发遇到的问题
数据加载中...
 
   



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

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