Seek advice on 2 SqlConnections algorithm

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom

    #1

    Seek advice on 2 SqlConnections algorithm

    Hi,

    I wrote a win application which use DataReader and while
    (reader.Read()) to read a table's data and then assign
    them to local variables for other methods to use.

    It is the first sqlconnection.

    Insides the while loop, I need to call a StoredProcedure
    to insert the data to another table. So, I made the 2nd
    sqlconnection insides the while loop of the 1st
    sqlconnection.

    They work fine. But, I think there should be better
    algorithm, e.g. just to use one SqlConnection.

    Anyone could give me some advice?

    Thanks
  • Marina

    #2
    Re: Seek advice on 2 SqlConnections algorithm

    You might want to consider just putting your data into a dataset, and then
    looping through that to call the stored procedure.

    "Tom" <kerocow@yahoo. com> wrote in message
    news:09ff01c394 e9$b52641e0$a00 1280a@phx.gbl.. .[color=blue]
    > Hi,
    >
    > I wrote a win application which use DataReader and while
    > (reader.Read()) to read a table's data and then assign
    > them to local variables for other methods to use.
    >
    > It is the first sqlconnection.
    >
    > Insides the while loop, I need to call a StoredProcedure
    > to insert the data to another table. So, I made the 2nd
    > sqlconnection insides the while loop of the 1st
    > sqlconnection.
    >
    > They work fine. But, I think there should be better
    > algorithm, e.g. just to use one SqlConnection.
    >
    > Anyone could give me some advice?
    >
    > Thanks[/color]


    Comment

    • Tom

      #3
      Re: Seek advice on 2 SqlConnections algorithm

      But, I need to pass each row of data to another method one
      by one.

      DataSet will fill all data from the sqlDataAdapter.


      [color=blue]
      >-----Original Message-----
      >You might want to consider just putting your data into a[/color]
      dataset, and then[color=blue]
      >looping through that to call the stored procedure.
      >
      >"Tom" <kerocow@yahoo. com> wrote in message
      >news:09ff01c39 4e9$b52641e0$a0 01280a@phx.gbl. ..[color=green]
      >> Hi,
      >>
      >> I wrote a win application which use DataReader and while
      >> (reader.Read()) to read a table's data and then assign
      >> them to local variables for other methods to use.
      >>
      >> It is the first sqlconnection.
      >>
      >> Insides the while loop, I need to call a StoredProcedure
      >> to insert the data to another table. So, I made the 2nd
      >> sqlconnection insides the while loop of the 1st
      >> sqlconnection.
      >>
      >> They work fine. But, I think there should be better
      >> algorithm, e.g. just to use one SqlConnection.
      >>
      >> Anyone could give me some advice?
      >>
      >> Thanks[/color]
      >
      >
      >.
      >[/color]

      Comment

      Working...