Hi there,
I have a .mdb file with 8 fields in temp table (import 8 fields from text files into temp), now firstly I need to import a part of text files into a field (called: ID) in access.
Examples my text files are: Z08121.A01607001.txt (need getting: 01607001) ; Z1231.A01203500.txt (need getting: 01203500) => this is my code for this problem:
Now i need to insert it into ID field in temp table but i don't know how to do. I inserted 8 field for content of each txt files. That is my code:
Then, in each my text file always contain this format at the first line:
BG$ddmmyyyy$number$number
and the last line:
EN$number$number$number
(This first line and last line in each txt file will be not inserted into access, i only get from the second line of txt file)
But I must get ddmmyyyy in the first line in txt file to insert a field (named: Received_Date) into temp table in access.
Plz help me, I don't know how to solve this problem...very urgent...
Thanks in advance!
I have a .mdb file with 8 fields in temp table (import 8 fields from text files into temp), now firstly I need to import a part of text files into a field (called: ID) in access.
Examples my text files are: Z08121.A01607001.txt (need getting: 01607001) ; Z1231.A01203500.txt (need getting: 01203500) => this is my code for this problem:
VB.NET:
Dim str As String
Dim rsl As DialogResult
With Me.OpenFileDialog1
.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
rsl = .ShowDialog()
If rsl = Windows.Forms.DialogResult.OK Then
Dim fi = OpenFileDialog1.FileName
txtNote.Text = OpenFileDialog1.FileName
Dim fileName2 As String = IO.Path.GetFileName(fi)
str = fileName2.Substring(fileName2.Length - 12, 8)
Me.txtNote.Text = str
End If
End With
Now i need to insert it into ID field in temp table but i don't know how to do. I inserted 8 field for content of each txt files. That is my code:
VB.NET:
strsql1 = "Insert into temp (F1,F2,F3,F4,F5,F6,F7,F8) Select * From [Text; FMT=Delimited;Database=\\server\Data\test;HDR=No].[" & fileName2 & "]"
Dim TextCommand As New OleDbCommand(strsql1, TextConnection)
Try
TextCommand.ExecuteNonQuery()
Catch myerror As Exception
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
End Try
BG$ddmmyyyy$number$number
and the last line:
EN$number$number$number
(This first line and last line in each txt file will be not inserted into access, i only get from the second line of txt file)
But I must get ddmmyyyy in the first line in txt file to insert a field (named: Received_Date) into temp table in access.
Plz help me, I don't know how to solve this problem...very urgent...
Thanks in advance!
Last edited: