Results 1 to 13 of 13

Thread: ADODB.Recordset Versus ADO.NET DataSets

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    Unhappy ADODB.Recordset Versus ADO.NET DataSets

    If I use the following to add records from one Database to another :

    VB Code:
    1. Do While Not rstHDNET.EOF
    2.  
    3.                 With rstLabel
    4.  
    5.                     .AddNew()
    6.  
    7.                     .Fields("PROD_CODE").Value = rstHDNET("Q$LITM").Value
    8.                     .Fields("PROD_DESC").Value = rstHDNET("Q$DSC").Value
    9.                     .Fields("PROD_PRICE").Value = Math.Round(rstHDNET("Q$SRP").Value, 2)
    10.  
    11.                     .Update()
    12.  
    13.                 End With
    14.  
    15.                 prgMain.Value = rstHDNET.AbsolutePosition
    16.                 rstHDNET.MoveNext()
    17.                 Application.DoEvents()
    18.  
    19.                 lblCount.Text = "Record Number " & rstHDNET.AbsolutePosition & " of " & rstHDNET.RecordCount
    20.  
    21.             Loop

    It will do around 130000 records in about 10 minutes.

    If I use a dataset and use the mydataadapter.update(mydataset, "tablename") it takes absolutley donkeys years. Like around 3 hours or something.

    Am I doing something wrong or what???

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    post the code for ado.net
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298
    VB Code:
    1. Dim myconnection As New OleDb.OleDbConnection( _
    2.             "Provider=Microsoft.JET.OLEDB.4.0;Data Source=c:\mydatabase.mdb")
    3.         Dim mydataadapter As New OleDb.OleDbDataAdapter("Select * From mytable", myconnection)
    4.         Dim mycommandbuilder As New OleDb.OleDbCommandBuilder(mydataadapter)
    5.         Dim mydataset As New DataSet()
    6.  
    7.         Dim myrow As DataRow
    8.  
    9.         mydataset.Clear()
    10.         mydataadapter.Fill(mydataset, "mytablename")
    11.  
    12.         Do While Not rstHDNET.EOF
    13.  
    14.             With rstLabel
    15.  
    16.                 myrow = mydataset.Tables("mytablename").NewRow
    17.  
    18.                 myrow.Item("PROD_CODE") = rstHDNET("Q$LITM").Value
    19.                 myrow.Item("PROD_DESC") = rstHDNET("Q$DSC").Value
    20.                 myrow.Item("PROD_PRICE") = Math.Round(rstHDNET("Q$SRP").Value * 1.175, 2)
    21.  
    22.                 mydataset.Tables("mytablename").Rows.Add(myrow)
    23.  
    24.             End With
    25.  
    26.             rstHDNET.MoveNext()
    27.         Loop
    28.  
    29.     End Sub

    The above code goes really quickly, but after this I need to update the data adapter to commit the records into the rstHDNET recordset. Right??

    I know I have missed the - mydataadapter.update(mydataset, "mytablename")

    So where should I put the update??? Inside the loop like I have in the first post?? Or outside the Loop???

    Either way it is incredibly slow and generally the program stop responding where or not I have the application.doevents() in the loop.

    Maybe I have got this ADO.NET thing all wrong and generally screwed it up.

    Please advise,


    Many thanks,


    Matt.

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    i would say put the update outside of the loop.

    Is it the update that is taking the time?
    Try putting it outside the loop and put a message box either side of it so we know if it is the bit taking ages.

    You code looks fine though. It's the way that i'd have done it (again that doesn't mean in the best way though!!!!)

    Nick
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298
    It is the update that is taking the time. It is mad.

    I know there is around 130,000 records in the database but the first example does it without even breaking sweat, but with the dataset it is ending up not responding. Weird indeed.

    Cheers

    Matt.

  6. #6
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    it's a shot in the dark but before filling your dataset try applying the tables schemea to it.

    myDA.FillSchema(myDS.Tables("whatever"), SchemaType.Mapped)

    if mapped doesn't work try source.

    I doubt it'll be the problem but worth a try!
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Umm. what exactly is your code doing. You are filling the dataset, but then what is this recordset you are looping?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What are you using for your UpdateCommand? Did you write it? Use the Wizard? Use the CommandBuilder?

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298
    This is what I am using for my update.

    mydataadapter.update(mydataset, "mytablename")

    Pretty standard I thought.

    Oh nswan I tried the Schema but no success. I thought the schema was just to handle the primary keys???????
    What is the difference between the mapped and source schema??

    The loop just runs through all the records in one database and adding them into another.

  10. #10
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    No need to do the loop. Just fill another table in the dataset with the fill just like you alreqady did once.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298
    Cander I see what you mean and yeah sure I agree, but the initial thing was that I couldn't understand why that it took so long (3 hours) to add records into a database whilst using a dataset and if I used and ado recordset it took 15 mins.

    I don't need
    Before I changed the loop using the adodb.recordset I was using a datareader but this was the reason I changed to the adodb.recordset because I thought that it may be that that was slowing the process down.

    VB Code:
    1. Do While (myDataReader.Read())
    2.  
    3.  
    4. Loop

    Would/Should using the loop create a 2:45 hour difference in the simple adding of records????

    Personally I wouldn't have thought so. There are not many programs that I would write, that would require mass transferring of data as this one does, but I was amazed at the length of time it took using DataSets. I was just enquiring to see whether or not I had missed something in my code.

    Thanks for all you help.
    Last edited by MattJH; Jul 8th, 2003 at 11:32 AM.

  12. #12
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    what is rsthdnet and rstlabel? is that your file your using to get info from? just curious cause I am trying to learn how to do this also.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298
    Hi Phantom,

    Well, rstHdnet is holding the information from one database table and the rstLabel is holding table information from another database.

    While I understand that using the DataSet feature from ADO.NET in VB.NET is basically an "offline"/"disconnected" version of the database table, I can't understand why the speed would have been sacrificed, with this newer version of ADO.

    I just can't understand it.

    It is weird.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width