| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 408 人关注过本帖
标题:[求助]哪里出了问题,总报错
只看楼主 加入收藏
山嘉阿黛儿
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-5-23
收藏
 问题点数:0 回复次数:0 
[求助]哪里出了问题,总报错
Private Sub Command1_Click()
CommonDialog1.DialogTitle = "打开文件"
CommonDialog1.Filter = "text files(*.txt)|*.txt|all files(*.*)|(*.*)"
CommonDialog1.InitDir = 0
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
'Me.Text1.Enabled = False

End Sub

Private Sub Command2_Click()

If Text1.Text = "" Then
MsgBox "请选择一个文件!"
End If

Dim temp As String

Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, temp '读出每条记录,然后判断含有的字段

InputDataBase (temp) 'function insert database
Loop
Close #1

Do While Not EOF(1) '遍历数据库的每行数据

a = GetDataFromDatabase(strCardType1, strCardType2) '形参是卡种1和卡种2
Loop
End Sub

Private Function GetDataFromDatabase(ByVal strCardType1 As String, strCardType2 As String)
Dim conn As New ADODB.Connection
Dim strSql As String
Dim strCombine As String

conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=" & App.Path & "db1.mdb;Persist Security Info=False"
conn.Open

strSql = "select * from a1 where 卡种1='" & strCardType1 & "' and 卡种2='" & strCardType2 & "'"
Set obRecordSet = conn.Execute strSql

strCombine = objRecordSet.Fields("序号") & objRecordSet.Fields("信用卡卡号") & objRecordSet.Fields("持卡人性别和姓名拼音")
&_ objRecordSet.Fields("有效期") &_ objRecordSet.Fields("写磁信息") & _objRecordSet.Fields("卡种类1")
& objRecordSet.Fields("卡种类2") & vbCrLf

Open strCardType1 & strCardType2.txt For Output As #2
Print #2, strCombine
Close #2

End Function

Public Function ConnectString(ByVal apppath As String) As String
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "data source=" & apppath & "db1.mdb"
End Function

Dim strSql As String
Dim strId As String
Dim strCardId As String
Dim strUserName As String
Dim strExpireDate As String
Dim strInfo As String
Dim strCardType1 As String
Dim strCardType2 As String

strId = Mid(Trim(InInfo), 0, 6)
strCardId = Mid(Trim(InInfo), 7, 16)
strUserName = Mid(Trim(InInfo), 24, 34)
strExpireDate = Mid(Trim(InInfo), 59, 4)
strInfo = Mid(Trim(InInfo), 64, 36)
strCardType1 = Mid(Trim(InInfo), 102, 2)
strCardType2 = Mid(Trim(InInfo), 104, 2)

strSql = "INSERT INTO a1 (序号,信用卡卡号,持卡人性别和姓名拼音,有效期,写磁信息,卡种类1,卡种类2) values (strId,strCardId,strUserName,strExpireDate,strInfo,strCardType1,strCardType2)"

conn.Execute strSql
End Function

Private Sub Command3_Click()
Unload Me
End Sub

搜索更多相关主题的帖子: files False 
2007-05-31 18:11
快速回复:[求助]哪里出了问题,总报错
数据加载中...
 
   



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

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