J
Justin Fancy
Hi everyone,
I need some help. I'm placing text files into a created database using
vb.Net. The problem is that, i need two seperate sql statements to add
both files because they are in different loops. My output comes out to
be as Follows:
TABLE
----------------------------------------------------
Field1 Field2
outputfile1
outputfile1
outputfile1
outputfile1
outputfile1
outputfile2
outputfile2
outputfile2
outputfile2
-----------------------------------------------------
I declared both fields Nullable so I wouldn't get an error, complaining
that the fields cannot be Null.
I need the "outputfile2" lines to be adjacent to the "outputfile1"
files. I understand why this is happening, I just can't think of
another way of adding the fields.
My code is as follows:
Sub ReadFiles()
File1 = "intDirectory.txt"
'Open the first file
sr = IO.File.OpenText(File1)
'Initialize counter
'Loop through Directory Listing file to load filepaths into an
array
Do While sr.Peek <> -1
lineFile1 = sr.ReadLine
Dim sb As New System.Text.StringBuilder(lineFile1)
sb.Replace("C:", "")
sb.Replace("x:", "")
sb.Replace("\", "/")
sb.Replace("wwwroot", "")
lineFile1 = sb.ToString()
'INSERT INTO TABLE
sSQL = "INSERT INTO Comparison(Internet_Directory)
VALUES('" & lineFile1.ToString & "')"
CreateStoredProc(sSQL)
counter += 1
Loop
sr.Close()
File2 = "IISLog.txt"
sr = IO.File.OpenText(File2)
sSQL = ""
Do While sr.Peek <> -1
lineFile2 = sr.ReadLine
'String Manipulation (Replace some unneeded text)
Dim sb2 As New System.Text.StringBuilder(lineFile2)
sb2.Replace("C:", "")
sb2.Replace("x:", "")
sb2.Replace("\", "/")
sb2.Replace("wwwroot", "")
lineFile2 = sb2.ToString()
'INSERT INTO TABLE
sSQL = "INSERT INTO Comparison(IIS_Logs) VALUES('" &
lineFile2.ToString & "')"
CreateStoredProc(sSQL)
counter2 += 1
Loop
sr.Close()
End Sub
I need some help. I'm placing text files into a created database using
vb.Net. The problem is that, i need two seperate sql statements to add
both files because they are in different loops. My output comes out to
be as Follows:
TABLE
----------------------------------------------------
Field1 Field2
outputfile1
outputfile1
outputfile1
outputfile1
outputfile1
outputfile2
outputfile2
outputfile2
outputfile2
-----------------------------------------------------
I declared both fields Nullable so I wouldn't get an error, complaining
that the fields cannot be Null.
I need the "outputfile2" lines to be adjacent to the "outputfile1"
files. I understand why this is happening, I just can't think of
another way of adding the fields.
My code is as follows:
Sub ReadFiles()
File1 = "intDirectory.txt"
'Open the first file
sr = IO.File.OpenText(File1)
'Initialize counter
'Loop through Directory Listing file to load filepaths into an
array
Do While sr.Peek <> -1
lineFile1 = sr.ReadLine
Dim sb As New System.Text.StringBuilder(lineFile1)
sb.Replace("C:", "")
sb.Replace("x:", "")
sb.Replace("\", "/")
sb.Replace("wwwroot", "")
lineFile1 = sb.ToString()
'INSERT INTO TABLE
sSQL = "INSERT INTO Comparison(Internet_Directory)
VALUES('" & lineFile1.ToString & "')"
CreateStoredProc(sSQL)
counter += 1
Loop
sr.Close()
File2 = "IISLog.txt"
sr = IO.File.OpenText(File2)
sSQL = ""
Do While sr.Peek <> -1
lineFile2 = sr.ReadLine
'String Manipulation (Replace some unneeded text)
Dim sb2 As New System.Text.StringBuilder(lineFile2)
sb2.Replace("C:", "")
sb2.Replace("x:", "")
sb2.Replace("\", "/")
sb2.Replace("wwwroot", "")
lineFile2 = sb2.ToString()
'INSERT INTO TABLE
sSQL = "INSERT INTO Comparison(IIS_Logs) VALUES('" &
lineFile2.ToString & "')"
CreateStoredProc(sSQL)
counter2 += 1
Loop
sr.Close()
End Sub