Getting double records from .csv files

Discussion in 'ASP .Net' started by =?Utf-8?B?UCBvZiBEaHVtcA==?=, Aug 19, 2005.

  1. Hi,
    I am getting some data from a .csv file through an aspx page. The total no
    of records are 744 while i'm getting 1500. I couldn't really figure it out.
    I'll write the code below.

    Code:
    
    Dim ExcelConnection As New OleDbConnection
    Dim ExcelCommand As New OleDbCommand
    Dim ExcelAdapter As New OleDbDataAdapter
    Dim ExcelDataset As New DataSet
    ExcelConnection = New
    OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathname +
    ";Extended Properties=Text;")
    ExcelConnection.Open()
    ExcelCommand = New OleDbCommand("SELECT * FROM " + filename,
    ExcelConnection)
    Dim myread As OleDbDataReader
    ExcelAdapter = New OleDbDataAdapter(ExcelCommand)
    myread = ExcelCommand.ExecuteReader
    
    'If myread.HasRows Then
    Dim sqlConn As SqlConnection
    sqlConn = New SqlConnection("Server=.;database=Nissan; User Id=sa;
    Password=testing")
    Dim sqlcmd As New SqlCommand
    sqlConn.Open()
    
    While myread.Read
    
    'sqlcmd.CommandText = "Insert imported (imp) values('" &
    myread.GetValue(5) & "')"
    'sqlcmd.Connection = sqlConn
    'sqlcmd.ExecuteNonQuery()
    Response.write (myread.getvalue(5))
    Response.write("<BR>")
    End While
    sqlConn.Close()
    
    
    Can anybody please let me know what am i doing wrong over here. Also is
    there any method in ado.net like ado (Recordset.EOF) because i couldn't find
    any method like this as well.
    Thanks in advance.

    ---------------------------------
    Prince of Dhump
    State Dhump of Himalaya

    (Life is short make the full use of it)
     
    =?Utf-8?B?UCBvZiBEaHVtcA==?=, Aug 19, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?UCBvZiBEaHVtcA==?=

    Guest

    Hi

    Where are you reading the CSV file or loading the CSV file.Is the path
    name having the CSV file name... Sqldatareader.read() return true if
    there are records in datareader , which is equivalent to .eof and .bof
    functionalities in old ADO.

    Shivprasad Koirala
    C# , VB.NET , SQL SERVER , ASP.NET Interview Questions
    http://www.geocities.com/dotnetinterviews/
     
    , Aug 19, 2005
    #2
    1. Advertising

  3. Hello shiv,

    Thank you for your reply. I solved this problem. But yes for your concern
    i'll answer the questions.
    Yes the path name is returing true. I'm reading the file from web server in
    a directory in there called import.
    I'm putting the server.mappath() function and its working because if i
    remove the file or change path it is actually giving me the error that the
    file couldn't be found.
    I have some more questions. In ASP sometimes we put any flag variable after
    recordset.movenext to do manythings. How can i implement that functionality
    in .net. Furthermore is there any property like recordcount in ado.net
    because i couldn't find any. Since i'm new to .net so can you please tell me
    if its there which object it lies with.

    Thanks

    ---------------------------------
    Prince of Dhump
    State Dhump of Himalaya

    (Life is short make the full use of it)



    "" wrote:

    > Hi
    >
    > Where are you reading the CSV file or loading the CSV file.Is the path
    > name having the CSV file name... Sqldatareader.read() return true if
    > there are records in datareader , which is equivalent to .eof and .bof
    > functionalities in old ADO.
    >
    > Shivprasad Koirala
    > C# , VB.NET , SQL SERVER , ASP.NET Interview Questions
    > http://www.geocities.com/dotnetinterviews/
    >
    >
     
    =?Utf-8?B?UCBvZiBEaHVtcA==?=, Aug 20, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luke Airig
    Replies:
    0
    Views:
    795
    Luke Airig
    Dec 31, 2003
  2. Sydex
    Replies:
    12
    Views:
    6,505
    Victor Bazarov
    Feb 17, 2005
  3. Michal Mikolajczyk
    Replies:
    0
    Views:
    658
    Michal Mikolajczyk
    Feb 13, 2004
  4. Skip Montanaro
    Replies:
    0
    Views:
    722
    Skip Montanaro
    Feb 13, 2004
  5. Replies:
    4
    Views:
    321
Loading...

Share This Page