aspx.vb to access a text file read one line untill the end of file

I have a  .txt file that contains numbers like this:

1637913
1638141
1638131
1636825
1638116

I want a SUB that uses FSO, opens the file and reads the first line and then I run an insert statement to insert that to my database...... it will keep reading the file until the end  of file.
LVL 9
apirniaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Elvio Lujan.Net Senior DeveloperCommented:
       Dim fs As New System.IO.StreamReader("filePath")

        Dim s As String = fs.ReadLine

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
apirniaAuthor Commented:
I think I need more help....This is what I have so far:
I added this on top: Imports System.IO

Private Sub GetLine()

        Label2.Text = ""

        Dim sr As System.IO.StreamReader = New System.IO.StreamReader("\\Etta\applications\CoverSheet\CoverSheet.txt")
        Dim s As String

        While (sr.Peek >= 0)
            s = sr.ReadLine
            MsgBox(s)
        End While
        sr.Close()

    End Sub


I will put my inser statement inplace of the MsgBox(s). But I can't get this to work yet.
I also want to do a check to make sure the line that I am reading is Numeric.

Elvio Lujan.Net Senior DeveloperCommented:
but what is MsgBox??? you can't use it in ASP.NET
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

apirniaAuthor Commented:
Ok.... then can I do:

TextBox1.Text = s
Elvio Lujan.Net Senior DeveloperCommented:
sure... tell me... you'r getting any erros?
apirniaAuthor Commented:
I get the following error:

Logon failure: unknown user name or bad password.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.IOException: Logon failure: unknown user name or bad password.

Source Error:



Line 46:         Dim sr As System.IO.StreamReader = New System.IO.StreamReader("\\Etta\applications\CoverSheet\CoverSheet.txt")

 
Elvio Lujan.Net Senior DeveloperCommented:
ok... you need to assing the permission to the file...
do right click in the file and go security tab and add the ASP.NET user
Elvio Lujan.Net Senior DeveloperCommented:
sorry you manage the permissions from the IIS...

verify the virtual directory in the IIS have read/wirte permisions
apirniaAuthor Commented:
All the permissions are checkd, file and IIS
Elvio Lujan.Net Senior DeveloperCommented:
and in the file into IIS?
apirniaAuthor Commented:
Ok, I resolved that Issue.

I had to add this in my Web.config

 <identity impersonate="true" userName="Domain\Username" password="password"/>


Now I get to work on the real stuff......


apirniaAuthor Commented:
Last question.....

I have a Directory with foldernames like this (date time format):

2006.02.08 16.55
2006.02.08 17.55

in my ASP.Net I want to get all the foldernames that start with todays date.

So I did:
CurrentDate = System.DateTime.Now.Year & "." & System.DateTime.Now.Month & "." & System.DateTime.Now.Day

But I dont know how to get the files names in the directory that starts with my CurrentDate??

Thanks

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.