Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
how i can browse files in my asp.net page and import the data from text file to my sql database?

i use table call test in sql and i use employs.txt file

i need help plz

thanks alot
Posted
Updated 24-May-12 10:14am
v2
Comments
Maciej Los 24-May-12 13:46pm    
Not clear... Please, be more specific.
Where is a problem?
What have you done till now?
maldef 24-May-12 15:16pm    
i creat table call test in my sql databes
and also i have aspx page i need to browse file employs.txt and also import data from employs.txt to test table
ZurdoDev 24-May-12 16:15pm    
modified formatting
Prosan 26-May-12 3:32am    
what is in the txt file. if you want whole data of txt file in a field than there is a solution to do it.
maldef 26-May-12 8:19am    
the txt file content is lik this
frist name & staffID

HILAL 69584
HILAL 69585
HILAL 69586
HILAL 69587
HILAL 69588
HILAL 69589
HILAL 69590

1 solution

use this function for reading txt file. and use your logic to save txtfile data to save
VB
Public Sub getdataFromTxtFile(ByVal FilePath As String)

        Dim r As System.IO.StreamReader = System.IO.File.OpenText(FilePath)
        Dim inputString As String
        inputString = ""
        Dim line As String
        Do
            line = r.ReadLine()
            
            If line IsNot Nothing Then
                inputString = inputString + line
                ' you can save this line in database or whole 
                ' file data which are coming in inputString variable 
            End If
        Loop While line IsNot Nothing
    End Sub
 
Share this answer
 
v2
Comments
maldef 28-May-12 6:52am    
thanks dear

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900