呵呵,对数据库字段属性一点概念都没有啊。
字段通用属性有字段名、字段类型、字段长度等,字段类型在type中,rs(7).type=adinteger,是数字的整数型类型。
建议你将MCOMSITE表中的所有字段设置为长度为50的文本类型,然后用下述代码,瞬间解决问题(你的代码有问题,循环20次,写20个同样的记录,这是错误的)
Private Sub Command2_Click()
Dim intFreeNumber As Integer
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim rsArray() As String, fdArray() As String
Dim i As Long, j As Long
Dim strTemp As String
Dim strfile As String
intFreeNumber = FreeFile()
Open App.Path & "\aa.txt" For Binary As #intFreeNumber
Do While Not EOF(intFreeNumber)
strTemp = Input(intFreeNumber, #intFreeNumber)
strfile = strfile & strTemp
Loop
Close #intFreeNumber
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
conn.Open
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "select *from [MCOMSITE]", conn, 1, 3
rsArray = Split(strfile, vbCrLf)
For i = 1 To UBound(rsArray)
fdArray = Split(rsArray(i), vbTab)
rs.AddNew
For j = 0 To rs.fileds.count-1
rs.fileds(j)=fdArray (j)
next
rs.update
Next i
rs.UpdateBatch
rs.close
conn.close
Set rs = Nothing
Set conn = Nothing
End Sub
字段通用属性有字段名、字段类型、字段长度等,字段类型在type中,rs(7).type=adinteger,是数字的整数型类型。
建议你将MCOMSITE表中的所有字段设置为长度为50的文本类型,然后用下述代码,瞬间解决问题(你的代码有问题,循环20次,写20个同样的记录,这是错误的)
Private Sub Command2_Click()
Dim intFreeNumber As Integer
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim rsArray() As String, fdArray() As String
Dim i As Long, j As Long
Dim strTemp As String
Dim strfile As String
intFreeNumber = FreeFile()
Open App.Path & "\aa.txt" For Binary As #intFreeNumber
Do While Not EOF(intFreeNumber)
strTemp = Input(intFreeNumber, #intFreeNumber)
strfile = strfile & strTemp
Loop
Close #intFreeNumber
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
conn.Open
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "select *from [MCOMSITE]", conn, 1, 3
rsArray = Split(strfile, vbCrLf)
For i = 1 To UBound(rsArray)
fdArray = Split(rsArray(i), vbTab)
rs.AddNew
For j = 0 To rs.fileds.count-1
rs.fileds(j)=fdArray (j)
next
rs.update
Next i
rs.UpdateBatch
rs.close
conn.close
Set rs = Nothing
Set conn = Nothing
End Sub