is there a way like in vb6(recordset.movenext) to move through in asp.net so a person can manually go through rows(both forword and backword)and display them on a form.
Backwards cannot be done in ADO.net without the creation of an offline dataset - creating a datareader is easy for forward-only reads.
You will need to create a dataadapter, and use it to fill a dataset which you can then navigate freely. If you have problems doing this, post back and i will help
Hello, this is some code I use to move forward and backwards throughs records. I running vb.net v2002 connecting to a SQL2000 database using intergrated security.
'Declare objects, use intergrated security to access Northwind db
Dim cnn1 As SqlConnection = _
New SqlConnection _
("Data Source=(local);" & "Integrated Security=SSPI;" & _
"Initial Catalog=northwind")
Dim myAdapter As SqlDataAdapter = New SqlDataAdapter( _
"SELECT * FROM customers ", cnn1)
Dim myDS As DataSet
Dim myDV As DataView
Dim myCurrencyManager As CurrencyManager
Dim relCustOrder As DataRelation
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
'Fill the DataSet and bind the fields...
FillDataSetAndView()
BindFields()
'Show the current record position...
ShowPosition()
'Write Exception message to the event log...
Dim log As EventLog = New EventLog()
log.Log = "NWind_Application"
log.Source = Me.Text
log.WriteEntry(er.ToString, EventLogEntryType.Error)
log.Close()
'Display message in StatusBar...
StatusBar1.Text = er.ToString
Finally
End Try
End Sub
Private Sub FillDataSetAndView()
'Initialize a new instance of the DataSet object...
myDS = New DataSet()
'Fill the DataSet object with data...
myAdapter.Fill(myDS, "customers")
'Set the DataView object to the DataSet object...
myDV = New DataView(myDS.Tables("Customers"))
'Set our CurrencyManager object to the DataView object...
myCurrencyManager = CType(Me.BindingContext(myDV), CurrencyManager)
I'm still not a fan of binding data directly to the GUI.
And the whole "scroll through records" thing has always bothered me. How useful is it? Making a user go one record at a time trying to find the one they want. It's faster and most users find it preferable to be able to see a filtered list of items so they can pick the one they want based off of some key fields, rather then scroll through the data, wait for an entire page of data to load.
Once you break free from the old Access format, and get away from directly bound data, moving through data becomes much more fluid and direct for the users.
I tend to agree with rick. select * from ... is never a good idea I mostly only get "one" record at a time. this thing would grind to a halt if you had a million records. using parameters to fill the insert, update and delete statements will render the databinding useless.
Believe me your users don't want to step thru a million records unless they work for the governement (like me).
Christiaan Baes
Belgium
If you want to get an answer read this FAQ faq796-2540 There's no such thing as a winnable war - Sting
thank you for your views guys(rick and chrissie1) & belive me i know exacly what you guys saying.this problem arise to me cos i'm new to .net and i want to find out how the old things are don in the new way.
i will try out your code "wearytraveller" and do remember this is asp.net and not just vb.net. threr are some things
that dosn't work in asp.net as in vb.net(from what i have experienced , eg:- msgbox don't work!)
I am sure it (SP2) doesnt block select *, this is a key part of the sql language and does have many uses, especially in rapid application development when data changes can be quite frequent.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.