Results 1 to 17 of 17

Thread: where is movenext ?

  1. #1

    Thread Starter
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117

    where is movenext ?

    hi
    How can I navigate throu records of a table?. Is there any Dataset or datareader methods for that?

    thanks
    when in doubt, win the trick

  2. #2

    Thread Starter
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117
    is anybody out there?
    when in doubt, win the trick

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Movenext still there ,

    after doing this , your bug will be resolved :

    1-in the solution explorer of your project , click COM tab and then add reference to Microsoft DAO 3.51 Object Library.
    (if you didn't find the file named AO350.DLL then copy it from VB6 CD or any website)
    2- declare your variables that store DB and RECORDSET in the general declaration of your Form as follow :

    VB Code:
    1. Dim db As DAO.Database
    2. Dim rec As DAO.Recordset

    3-your done now !!!
    Pirate

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You can just travel through the array/collection of datarows in the dataset.

    VB Code:
    1. Static cnt as Integer
    2. Msgbox (ds.Tables(0).Rows(cnt).Item(0).Value)
    3.  
    4. 'to move next
    5. cnt+=1
    6. If cnt>ds.Tables(0).Rows.Count then cnt=0

  5. #5

    Thread Starter
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117
    thanks edneeis,
    now I'm using such similar code. But I've to make it sure movnext is not there.
    thanks
    when in doubt, win the trick

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by pirate
    Movenext still there ,

    after doing this , your bug will be resolved :

    1-in the solution explorer of your project , click COM tab and then add reference to Microsoft DAO 3.51 Object Library.
    (if you didn't find the file named AO350.DLL then copy it from VB6 CD or any website)
    2- declare your variables that store DB and RECORDSET in the general declaration of your Form as follow :

    VB Code:
    1. Dim db As DAO.Database
    2. Dim rec As DAO.Recordset

    3-your done now !!!
    Pirate
    did you get the above code worked ??

  7. #7
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    Pirate - that code is old. This is VB.NET and DAO is dead. Use DataSets or DataReader to get data back.
    Although backwards compatible there is no point in using those techniques. Just my thoughts.
    Wind and waves resolves all problems.

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: where is movenext ?

    Originally posted by afterMoon
    hi
    How can I navigate throu records of a table?. Is there any Dataset or datareader methods for that?
    thanks
    OK, listen you told me that you wanted the MOVENEXT method which is only avilable in VB6. That what I know .If you think this method is out of date you should've mentioned which VB method you're looking for.


    Just my thoughts.

  9. #9
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    He said "Is there any Dataset or datareader methods for that?"

    That doesn't mean he literally wants the movenext method. He did post in a VB.Net forum, which means that he wanted a .Net answer.

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    hellswraith ,
    First , have a look at the title " where is movenext ?" before reading the content .
    Second , I've tried this code and it worked in VB.NET , and I am 100% sure
    thanx anyway

  11. #11
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Sure it works in .Net, but that isn't the way your supposed to do it. There are much more efficient ways to do it now. Leave COM and VB6 ways behind. Just look at Edneeis's way.

  12. #12
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    There's about a million different ways of navigating through .NET "resultsets". Here's one way of doing it:
    VB Code:
    1. Imports System
    2. Imports System.Data
    3. Imports System.Data.SqlClient
    4. Namespace DataNavigation
    5.     Module MainApp
    6.         Public Sub Main()
    7.             Dim connString As String = "user id=sa;password=sa;database=pubs;server=manson;"
    8.             Dim cn As SqlConnection = New SqlConnection(connString)
    9.             Dim cmdText As String = "Select * From Authors"
    10.             Dim cmd As SqlCommand = New SqlCommand(cmdText, cn)
    11.             Dim ds As DataSet = New DataSet("Authors")
    12.             Dim da As SqlDataAdapter
    13.             Dim dtable As DataTable
    14.             Dim drow As DataRow
    15.             Dim dcol As DataColumn
    16.             da = New SqlDataAdapter(cmd)
    17.             da.Fill(ds)
    18.             dtable = ds.Tables(0)
    19.             For Each drow In dtable.Rows
    20.                 For Each dcol In dtable.Columns
    21.                     Console.Write(drow(dcol.ColumnName).ToString())
    22.                     Console.Write(",")
    23.                 Next
    24.                 Console.WriteLine()
    25.             Next
    26.             Console.ReadLine()
    27.         End Sub
    28.     End Module
    29. End Namespace

  13. #13
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by hellswraith
    Sure it works in .Net, but that isn't the way your supposed to do it. There are much more efficient ways to do it now. Leave COM and VB6 ways behind. Just look at Edneeis's way.

    I think a user has the choice to use VB6 ways,as you said,as long as it's still supported in .NET.He asked about that specific method "movenext movenext movenext........."!!!

    Tip of the Day!
    MS will never support old and inefficient ways in .NET,so COMs is welcomed to work out.

  14. #14

    Thread Starter
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117
    Order! Order!
    I 've chosen Edneeis way!. I searched for a VB.NET method, not a DAO method. I used the word 'MOVENEXT' just for better communication.

    Anyway Thanks to all.
    when in doubt, win the trick

  15. #15
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    Of course MS will support old inefficent ways, they are a large company who know their developers. Why alienate 3 million developers of vb6 by offering no backwards compatability??? VB.NET is a large, very good (in my opinion),step forward but it is once again a progression in the language. If you want a completely new language then look to C#. Anyway just my thoughts!
    Wind and waves resolves all problems.

  16. #16
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    pirate,
    Don't get so upset, I was just saying that you need to read beyond the title sometimes. COM interop is great when it is needed, but in this case, it isn't needed. There is to much overhead using COM components in .Net. Always try to find a .Net way to do it before going with COM.

  17. #17
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    afterMoon , you got to be more precise & specific posting your thread. OK ???

    alright hellswraith ,you got what I was trying to say .

    hey cim3 , no need to talk about MS and C# coz you will open an unend-cirlce , moreover , all what you've said was nothing to do with this post.

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