adodb.recordset.recordcount

sdyqingdao 2001-07-20 04:00:23
how to get it at run time?
&,what is link table?
...全文
104 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sdyqingdao 2002-02-04
  • 打赏
  • 举报
回复
结了
wweilinux 2002-01-31
  • 打赏
  • 举报
回复
通过访问注册表,写到run字键中就可开机自动运行。要链接表,先要建一个表,然后将ado控件的database属性设为你建的数据库名,recordsouce属性设为你建的表名。recordset是表中记录集属性,可通过数组对表中字段进行操作。recordcount则是统计表中字段数。
jett 2002-01-31
  • 打赏
  • 举报
回复
什么意思?
ferrytang 2002-01-31
  • 打赏
  • 举报
回复
我来~~~~~
你要问什么?
sdyqingdao 2002-01-31
  • 打赏
  • 举报
回复
谁来留言,让我结贴
vb学生管理系统源代码 部分代码 Public UserName As String Public txtSQL As String 'use to store record SQLsentence Public dream As ADODB.Recordset 'use to store record object Public Msgtext As String '用来存放返回信息 Public OK As Boolean ' 'Public db As String Public Sub highlight() With Screen.ActiveForm If (TypeOf .ActiveControl Is TextBox) Then .ActiveControl.SelStart = 0 .ActiveControl.SelLength = Len(.ActiveControl) End If End With End Sub Sub Main() 'Dim Login As New Login 'Login.Show vbModal 'f Not Login.OK Then 'Login Failed so exit app ' End 'End If 'Unload studentmdi ' Set login = New login login.Show End Sub Public Function connectstring() As String connectstring = "Provider=Microsoft.jet.OLEDB.3.51;Data source=f:\schoolgroup\school.mdb" End Function 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$(sTokens(0))) Then cnn.ExecuteSQL Msgstring = sTokens(0) & "query successful" Else Set rst = New ADODB.Recordset rst.Open Trim(SQL), cnn, adOpenKeyset, adLockOptimistic Set ExecuteSQL = rst Msgstring = "查询到" & rst.RecordCount & " 条记录" End If executeSQL_exit: Set rst = Nothing Set cnn = Nothing Exit Function ExecuteSQL_Error: Msgstring = "查询错误:" & err.Description Resume executeSQL_exit End Function Public Function Testtxt(txt As String) As Boolean If Trim(txt) = "" Then Testtxt = False Else Testtxt = True End If End Function
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
部分源代码: 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

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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