dbreader

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • microsoft.news.com

    dbreader

    How can I this but using the dbReader instead of the streamreader and get
    all the items instead of the last one in my text file i'm populating?

    this works fine:
    StreamReader sr = new StreamReader("f ile.txt");

    string lines = sr.ReadLine();
    while((line = sr.ReadLine()) !=null)
    {
    // loops thru and writes the data to the new file
    }

    now i need to do the same but using a dbreader
    how can I get that working? I'm using
    while (dbReader.Read( ))
    {
    //loops thru but its only writing the last data item to the new file
    }

    what else do i need to do to get this to write all the items to the new file
    instead of only the last one?








    S

    while ((line = sr.ReadLine()) !=null)

    {


  • Bjorn Abelli

    #2
    Re: dbreader


    "microsoft.news .com" <me@me.com> wrote...[color=blue]
    > How can I this but using the dbReader instead of the
    > streamreader and get all the items instead of the last
    > one in my text file i'm populating?[/color]

    What do you mean by "dbreader"?

    Is it possibly an OdbcDataReader or similar, implementing the IDataReader
    interface?

    Are you reading from the same text file?
    [color=blue]
    > this works fine:
    > StreamReader sr = new StreamReader("f ile.txt");
    >
    > string lines = sr.ReadLine();
    > while((line = sr.ReadLine()) !=null)
    > {
    > // loops thru and writes the data to the new file
    > }
    >
    > now i need to do the same but using a dbreader
    > how can I get that working? I'm using
    > while (dbReader.Read( ))
    > {
    > //loops thru but its only writing the last data item to the new file
    > }
    >
    > what else do i need to do to get this to write all
    > the items to the new file instead of only the last one?[/color]

    How did you populate the IDataReader to start with?

    What do you mean by "items"?

    What do the records look like?


    // Bjorn A


    Comment

    • microsoft.news.com

      #3
      Re: dbreader

      I'm connecting to an excel file as the datasource, so I'm using
      OleDbConnection and OleDbDataReader .
      I need to read the excel file which is working, but when i try to populate a
      new file, its only displaying the lat record it reads from the excel file.

      items = dataitems/data


      "Bjorn Abelli" <bjorn_abelli@D oNotSpam.hotmai l.com> wrote in message
      news:eChOrmcYFH A.3840@tk2msftn gp13.phx.gbl...[color=blue]
      >
      > "microsoft.news .com" <me@me.com> wrote...[color=green]
      >> How can I this but using the dbReader instead of the
      >> streamreader and get all the items instead of the last
      >> one in my text file i'm populating?[/color]
      >
      > What do you mean by "dbreader"?
      >
      > Is it possibly an OdbcDataReader or similar, implementing the IDataReader
      > interface?
      >
      > Are you reading from the same text file?
      >[color=green]
      >> this works fine:
      >> StreamReader sr = new StreamReader("f ile.txt");
      >>
      >> string lines = sr.ReadLine();
      >> while((line = sr.ReadLine()) !=null)
      >> {
      >> // loops thru and writes the data to the new file
      >> }
      >>
      >> now i need to do the same but using a dbreader
      >> how can I get that working? I'm using
      >> while (dbReader.Read( ))
      >> {
      >> //loops thru but its only writing the last data item to the new file
      >> }
      >>
      >> what else do i need to do to get this to write all
      >> the items to the new file instead of only the last one?[/color]
      >
      > How did you populate the IDataReader to start with?
      >
      > What do you mean by "items"?
      >
      > What do the records look like?
      >
      >
      > // Bjorn A
      >
      >[/color]


      Comment

      • Bjorn Abelli

        #4
        Re: dbreader


        "microsoft.news .com" <me@me.com> wrote...
        [color=blue]
        > I'm connecting to an excel file as the datasource,
        > so I'm using OleDbConnection and OleDbDataReader .
        > I need to read the excel file which is working, but
        > when i try to populate a new file, its only displaying
        > the lat record it reads from the excel file.
        >
        > items = dataitems/data[/color]

        It sound to me that you have some logical error in your code, either when
        reading from the Excel file, or when writing to the text file, or both...

        If you could give some more code, such as what your CommandText looks like,
        how you open/close the output file, etc. Maybe especially what you do inside
        the loop, and between the loop and the closing of the output file.
        [color=blue][color=green][color=darkred]
        >>> while (dbReader.Read( ))
        >>> {
        >>> // loops thru but its only writing
        >>> // the last data item to the new file
        >>> }[/color][/color][/color]


        // Bjorn A


        Comment

        Working...