这是我写的一个程序,主要是将一个dat文件中的数据读入并存到access数据库中,请哪位帮忙看看有什么问题,谢谢! Dim CN As New ADODB.Connection Dim Rs As New ADODB.Recordset Set CN =new ADODB.Connection
‘建立连接对象 Set Rs= New ADODB.Recordset
‘定义一个记录集 CN.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" C:\Documents and Settings\xuanfeng\桌面\ qixiang.mdb ")
‘打开数据库 Rs.open”qixiang”,CN,adopenkeyset,adlockoptimistic,adcmdtable
‘打开记录集 Open " C:\Documents and Settings\xuanfeng\桌面\直接收集\CR1000_TenMin.dat" For Input As #1
‘打开数据文件 Rs.Fields(“TIMESTAMP”)=b(0) ‘年份时间 Rs.Fields(“ RECORD”)= b(1) ‘记录 Rs.Fields (“batt_volt_Min”)= b(2)‘数据 Rs.Fields (“Ta_Avg”)=b(4) Rs.Fields (“RH_Avg”)=b(5) Rs.Fields (“Pvapor_Avg”)=b(6) Rs.Fields (“WD_std”)=b(9) Rs.Fields (“Rain_Tot”)=b(10) Rs.Fields (“T_109_Avg”)=b(11) Rs.Fields (“Rs_Avg”)=b(12) Rs.Fields (“LWS_Avg”)=b(13) Rs.Fields (“LWS_RH”)=b(14) Rs.Fields (“CO2_Avg”)=b(16) Rs.Fields (“DirRad_Avg”)=b(17) Rs.Fields (“Sunduration_Tot”)=b(18) Rs.Fields (“Evap_Tot”)=b(19) Rs.Fields (“Watlev”)=b(20) Rs.Fields (“TS”)=b(21)
Rs.Fields (“RN”)=b(22)
End Sub |