hi
How can I navigate throu records of a table?. Is there any Dataset or datareader methods for that?
thanks
Printable View
hi
How can I navigate throu records of a table?. Is there any Dataset or datareader methods for that?
thanks
is anybody out there?
Movenext still there ,
after doing this , your bug will be resolved :D :
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 :DAO350.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:
Dim db As DAO.Database Dim rec As DAO.Recordset
3-your done now !!! ;)
Pirate
You can just travel through the array/collection of datarows in the dataset.
VB Code:
Static cnt as Integer Msgbox (ds.Tables(0).Rows(cnt).Item(0).Value) 'to move next cnt+=1 If cnt>ds.Tables(0).Rows.Count then cnt=0
thanks edneeis,
now I'm using such similar code. But I've to make it sure movnext is not there.
thanks
did you get the above code worked ??Quote:
Originally posted by pirate
Movenext still there ,
after doing this , your bug will be resolved :D :
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 :DAO350.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:
Dim db As DAO.Database Dim rec As DAO.Recordset
3-your done now !!! ;)
Pirate
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.
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.Quote:
Originally posted by afterMoon
hi
How can I navigate throu records of a table?. Is there any Dataset or datareader methods for that?
thanks
Just my thoughts.;)
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.
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
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.
There's about a million different ways of navigating through .NET "resultsets". Here's one way of doing it:
VB Code:
Imports System Imports System.Data Imports System.Data.SqlClient Namespace DataNavigation Module MainApp Public Sub Main() Dim connString As String = "user id=sa;password=sa;database=pubs;server=manson;" Dim cn As SqlConnection = New SqlConnection(connString) Dim cmdText As String = "Select * From Authors" Dim cmd As SqlCommand = New SqlCommand(cmdText, cn) Dim ds As DataSet = New DataSet("Authors") Dim da As SqlDataAdapter Dim dtable As DataTable Dim drow As DataRow Dim dcol As DataColumn da = New SqlDataAdapter(cmd) da.Fill(ds) dtable = ds.Tables(0) For Each drow In dtable.Rows For Each dcol In dtable.Columns Console.Write(drow(dcol.ColumnName).ToString()) Console.Write(",") Next Console.WriteLine() Next Console.ReadLine() End Sub End Module End Namespace
Quote:
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.
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.
:D
Anyway Thanks to all.
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!
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.
afterMoon , you got to be more precise & specific posting your thread. OK ???
alright hellswraith ,you got what I was trying to say .:D
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.