送分的问题,快来抢啊!(rst.recordcount)

rwj81 2003-09-10 04:23:57
我的ASP代码如下:
set rst_view = Server.CreateObject("ADODB.Recordset")
rst_view.ActiveConnection = MM_cnn_incoming_STRING
sqlstr=session("sqlstr")
rst_view.Source = sqlstr
rst_view.CursorType = 0
rst_view.CursorLocation = 2
rst_view.LockType = 3
rst_view.pagesize=8
rst_view.Open()

totalmessage=rst_view.recordcount
totalpage=rst_view.pagecoun

记录集绝对打开了,并且有记录,但rst_view.recordcount和rst_view.pagecoun
的值却始终是-1,何解???
...全文
39 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
huhan3 2003-09-10
  • 打赏
  • 举报
回复
rst_view.CursorType = 3
gshope 2003-09-10
  • 打赏
  • 举报
回复
rst_view.CursorType = 3
rst_view.LockType = 1

peytonzwt 2003-09-10
  • 打赏
  • 举报
回复
我也遇到这个问题了,是数据库的问题啊,数据库不支持。
部分源代码: Private Sub Command1_Click() Dim sql As String Dim param As ADODB.Parameter Dim cmd As ADODB.Command Set cmd = New ADODB.Command Set param = New ADODB.Parameter sql = "select * from book where [图书编码]= ? " If Command1.Caption = "添加记录" Then Command1.Caption = "确 定" Command2.Enabled = False '屏蔽删除、修改、下一记录、上一记录按钮,避免出现数据库错误 Command3.Enabled = False Command4.Enabled = False cmdmodify.Enabled = False rst.AddNew Else If Text1.Text = "" Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "图书编号不能为空!" Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" Exit Sub End If With param .Direction = adParamInput .Type = adBSTR .Size = 8 .Value = Text1.Text End With cmd.Parameters.Append param cmd.CommandText = sql cmd.CommandType = adCmdText Set cmd.ActiveConnection = con Set rst1 = cmd.Execute If rst1.RecordCount > 0 Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "此书号已经存在!" rst.Cancel Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True cmdmodify.Enabled = True Command1.Caption = "添加记录" Command2.Enabled = True Exit Sub End If rst.Update Command2.Enabled = True '数据库更新结束后才可以点击其他几个按钮 Command3.Enabled = True Command4.Enabled = True cmdmodify.Enabled = True Command1.Caption = "添加记录" End If End Sub 修改图书记录操作 Private Sub cmdmodify_Click() '修改记录按钮 Dim sqlstr As String Dim rst1 As New ADODB.Recordset Dim param As ADODB.Parameter Dim cmd As ADODB.Command Set cmd = New ADODB.Command Set param = New ADODB.Parameter sqlstr = "select * from book where [图书编码]= '" & Trim(Text1.Text) & "'" With param .Direction = adParamInput .Type = adBSTR .Size = 8 .Value = Text1.Text End With cmd.Parameters.Append param cmd.CommandText = sqlstr cmd.CommandType = adCmdText Set cmd.ActiveConnection = con Set rst1 = cmd.Execute If rst1.RecordCount > 0 Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "此书号已经存在!" rst.Cancel Exit Sub End If rst.Update frmMsg.Show frmMsg.info.Visible = True frmMsg.Text1.Text = "修改成功!" End Sub 添加职工信息 Private Sub Command1_Click() '添加记录 Dim sql As String Dim param As ADODB.Parameter Dim cmd As ADODB.Command Set cmd = New ADODB.Command Set param = New ADODB.Parameter sql = "select * from worker where [工号]= ? " If Command1.Caption = "添加记录" Then Command1.Caption = "确 定" Command2.Enabled = False Command3.Enabled = False Command4.Enabled = False rst.AddNew Else If Text1.Text = "" Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "职工编号不能为空!" Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" Exit Sub End If With param .Direction = adParamInput .Type = adBSTR .Size = 8 .Value = Text1.Text End With cmd.Parameters.Append param cmd.CommandText = sql cmd.CommandType = adCmdText Set cmd.ActiveConnection = con Set rst1 = cmd.Execute '检测职工编号是否存在防止主键冲突 If rst1.RecordCount > 0 Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "此职工编号已经存在!" rst.Cancel Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" Exit Sub End If rst.Update Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" End If End Sub
SQL+VB做成的licit Public gUserName As String Public gUserKind As String Public gEmployeeId As String Public gLoginSucceeded As Boolean Public Const BLUE = &HFF0000 Public Const WHITE = &H80000005 Sub Main() Dim fLogin As New frmLogin '启动登录窗体 fLogin.Show vbModal '装入并显示模式窗体。 If Not gLoginSucceeded Then MsgBox "系统启动失败,请重试!", vbOKOnly + vbExclamation, "警告" End If Unload fLogin End Sub Public Function ConnectString() As String ConnectString = "Provider=SQLOLEDB.1;Password=sa;User ID=sa;Initial Catalog=DBManPower;Data Source=127.0.0.1;" End Function Public Function ExecuteSQL(ByVal SQL As String, rst As ADODB.Recordset, _ Optional enableWrite As Boolean = True) As Boolean Dim con As ADODB.Connection Dim sTokens() As String On Error GoTo Execute_Error sTokens = Split(SQL) Set con = New ADODB.Connection con.Open ConnectString '打开数据库 Set rst = New ADODB.Recordset If enableWrite Then '读写方式 rst.Open Trim$(SQL), con, adOpenStatic, adLockOptimistic Else '只读方式 rst.Open Trim$(SQL), con, adOpenStatic, adLockReadOnly End If ExecuteSQL = True Exit Function Execute_Error: ExecuteSQL = False Exit Function End Function Public Function DBExist(ByVal SQL As String) As Integer Dim con As ADODB.Connection Dim sTokens() As String Dim flag As String Dim rst As ADODB.Recordset sTokens = Split(SQL) Set con = New ADODB.Connection con.Open ConnectString flag = ExecuteSQL(SQL, rst, False) '判断该记录是否存在 If rst.RecordCount <> 0 Then DBExist = rst.RecordCount Else DBExist = 0 End If con.Close End Function Public Function txtIsNull(txt As TextBox) As Boolean If Trim(txt.Text) = "" Then txtIsNull = True txt.SetFocus txt.BackColor = BLUE Else txtIsNull = False End If

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧