1.服务器端的recordset方可使用recordcount
解决方案 »
- 用VB,运行自动记录目前时间并添加到一个文本文件要怎么写?
- 如何在datagrid中直接修改数据(改了之后自动保存到数据库中)
- 奇怪﹐ACCESS中VBA不支持控件的ZOrder方法﹖
- 请问在莞城的程序员有几位啊?
- 怎么从网络计算机copy文件?
- 请问怎么用打印机打印条形码呢?
- 如何把ado查询的数据导入Excel 2000中啊
- 怎么用System.Security.Cryptography下的方法加解密字符串!
- 键盘?
- 请问怎样使ado的recordset根据datagrid的任何改变自动更新数据(而不需要使用update、refresh等命令)?
- 怎样把通过inet从web中取得的utf-8编码的乱嘛转换成正确的byte数组,以便utf-8解码?Help
- vb6--help me
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fso As Scripting.FileSystemObject
Dim fExport As TextStream
Dim strLine As String
If Trim(txtText.Text) = "" Then
MsgBox "ÇëÖ¸¶¨µ¼³öÎļþ", , "TOEIC"
cmdDialog.SetFocus
Exit Sub
End If
If Dir(txtText.Text) <> "" Then
MsgBox "ÇëÖØÐÂÖ¸¶¨Ò»¸öеĵ¼³öÎļþ", , "TOEIC"
cmdDialog.SetFocus
Exit Sub
End If
lStr = GetSelect(iChoice)
If lStr = "" Then Exit Sub
On Error GoTo ErrorHandle1
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open gstrConnect
rs.CursorLocation = adUseClient
rs.Open lStr, cn, adOpenKeyset, adLockBatchOptimistic
lblNum1.Caption = Trim(Str(rs.RecordCount))
If rs.RecordCount = 0 Then GoTo ErrorHandle1
Set fso = New Scripting.FileSystemObject
Set fExport = fso.CreateTextFile(txtText.Text, True, False)
rs.MoveFirst
Do While Not rs.EOF
With rs
strLine = Trim(.Fields("guid")) & Chr(9) & _
Trim(.Fields("cardid")) & Chr(9) & _
.Fields("listenscore") & Chr(9) & _
.Fields("readscore") & Chr(9) & _
.Fields("totalscore")
fExport.WriteLine strLine
lblNum2.Caption = Trim(Str(Val(lblNum2.Caption) + 1))
DoEvents
End With
rs.MoveNext
Loop
ErrorHandle2:
On Error Resume Next
fExport.Close
Set fExport = Nothing
Set fso = Nothing
ErrorHandle1:
If Err.Number <> 0 Then MsgBox Err.Description, , "TOEIC"
On Error Resume Next
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End SubPrivate Sub Form_Load()
Call InitDbf
iChoice = 0
End Sub
Private Sub OptScore_Click(Index As Integer)
cboExam.Visible = IIf(Index = 1, True, False)
cboSchool.Visible = IIf(Index = 2, True, False)
cboRoom.Visible = IIf(Index = 3, True, False)
txtCardID.Visible = IIf(Index = 4, True, False)
txtRegisterID.Visible = IIf(Index = 5, True, False)
iChoice = Index
End SubPublic Sub InitDbf()
Dim cn As New ADODB.Connection
On Error GoTo ErrorHandle
cn.Open gstrConnect
Set rsExam = New ADODB.Recordset
rsExam.CursorLocation = adUseClient
rsExam.Open "select examid,examcity + ' ' + convert(char(10),examdate,126) AS examinfo from te_exam", _
cn, adOpenStatic, adLockReadOnly
Set rsExam.ActiveConnection = Nothing
Set cboExam.RowSource = rsExam
cboExam.ListField = "examinfo"
cboExam.BoundColumn = "examid"
Set rsSchool = New ADODB.Recordset
rsSchool.CursorLocation = adUseClient
rsSchool.Open "select schoolid,schoolid + ' ' + schoolname as schoolinfo from te_school", cn, adOpenStatic, adLockReadOnly
Set rsSchool.ActiveConnection = Nothing
Set cboSchool.RowSource = rsSchool
cboSchool.ListField = "schoolinfo"
cboSchool.BoundColumn = "schoolid"
Dim lStr As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fso As Scripting.FileSystemObject
Dim fExport As TextStream
Dim strLine As String
Dim i AS integer On Error GoTo ErrorHandle1
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open gstrConnect
rs.CursorLocation = adUseClient
rs.Open "select * from te_score", cn, adOpenKeyset, adLockBatchOptimistic
lblNum1.Caption = Trim(Str(rs.RecordCount))
If rs.RecordCount = 0 Then GoTo ErrorHandle1
Set fso = New Scripting.FileSystemObject
Set fExport = fso.CreateTextFile("c:\export.dat", True, False)
rs.MoveFirst
i = 0
Do While Not rs.EOF
i = i + 1
if i = 10
fExport.WriteLine rs!A
i = 0
else
fExport.Write rs!A
i = i + 1
end if
rs.MoveNext
Loop
ErrorHandle2:
On Error Resume Next
fExport.Close
Set fExport = Nothing
Set fso = Nothing
ErrorHandle1:
If Err.Number <> 0 Then MsgBox Err.Description, , "TOEIC"
On Error Resume Next
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fso As Scripting.FileSystemObject
Dim fExport As TextStream
Dim strLine As String
Dim i AS integer On Error GoTo ErrorHandle1
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open gstrConnect
rs.CursorLocation = adUseClient
rs.Open "select * from te_score", cn, adOpenKeyset, adLockBatchOptimistic
lblNum1.Caption = Trim(Str(rs.RecordCount))
If rs.RecordCount = 0 Then GoTo ErrorHandle1
Set fso = New Scripting.FileSystemObject
Set fExport = fso.CreateTextFile("c:\export.dat", True, False)
rs.MoveFirst
i = 0
Do While Not rs.EOF
i = i + 1
if i = 10
fExport.WriteLine rs!A
i = 0
else
fExport.Write rs!A
i = i + 1
end if
rs.MoveNext
Loop
ErrorHandle2:
On Error Resume Next
fExport.Close
Set fExport = Nothing
Set fso = Nothing
ErrorHandle1:
If Err.Number <> 0 Then MsgBox Err.Description, , "TOEIC"
On Error Resume Next
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing