[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB.NET Databinding

Posted on 2003-11-11
6
Medium Priority
?
1,277 Views
Last Modified: 2012-06-21
Hi

I have tens of thousands of records on a SQL Server database, and I wish to create an interface so an end user can edit the records and move back and forth between them,   very similarly to the interface in MS Access.  The end user will have the software locally and it will access the data on a DB Server over the internet.

I’m not sure how to approach the situation.  I tried to use the SqlDataAdapter and set the SelectCommand to return all the records, and then fill a dataset with the results and then bind each of my textboxes to a field in that dataset.

This works fine, however the time it takes first to initialise and display the first record, and then the time it takes to move back and forth between records is unacceptable even over a 256k link.

I then tried to manually generate a SQL statement to return the desired record when and where it is needed (i.e., move to next or last record).  This gives a much better response time, however when I fill my dataset with the record that the SQL statement returns, I the data bindings don’t refresh.  

I have checked and the correct data is in the dataset but it seems that the bindings aren’t picking up the change and updating the values in the textboxes.  I have tried to refresh the bindings using the CurrencyManager but it still does not work.  Is it to do with the Fill method that I'm using with the adapter?

I was wondering if there is another way of approaching the problem, or perhaps there is something I was doing wrong in my 2 attempts.  Either way is acceptable, but if I use the later one, how could I make the bound textboxes reflect the changes in the dataset?

Your help will be much appreciated.

Thanks,
Michael
0
Comment
Question by:Xavior2K3
6 Comments
 
LVL 10

Expert Comment

by:GoodJun
ID: 9725345
Try to turn the vieststate of the grid off. call the grid.Databind() for each postback.
0
 
LVL 1

Author Comment

by:Xavior2K3
ID: 9725411
Sorry i might not have made myself clear im using textboxes instead of datagrids.  How could i refresh the textboxes to display the changed dataset?
0
 
LVL 6

Expert Comment

by:pillbug22
ID: 9725547
Your button for next/previous would have to re-bind the textboxes each time.

I know you mentioned a slow response time for returning so many records at once - have you thought about displaying only the top-level (very basic, but record-specific identifiable) information, then letting the user select a record to show the details of that record?

That way, you are basically filtering the information, not pulling back 30 fields for each record when the user really only needs all 30 for the 1 record.
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
LVL 1

Author Comment

by:Xavior2K3
ID: 9726360
Thanks for the response, one problem i have though is that when the user selects a record they want to view more details about, i would get that particular record from the database and repopulate the dataset that the textboxes are bound to.  This is all ok but when i populate the dataset with the new data in, the textboxes dont change to the new data.  When i try to re-bind them it says they are already bound from when i bound them the first time.  Would i have to somehow clear the old bind and re-bind it again? If so how? Otherwise any suggestions?

Thanks
0
 
LVL 1

Accepted Solution

by:
rushtosachin earned 1000 total points
ID: 9727160
i think u r concerned abt rebind the text boxes....do 1 thing.....put database field name in tag each of the text boxes...it's just one time task.....then you can use the following function....you just need to pass FORM NAME  AND DATATABLE AND IT'S ROW  POSITION (populate it n pass it whenever needed) as an argument.

        Public Sub BindControlsToTaggedData(ByRef Form_Name As Form, ByRef pors As DataTable, ByVal RowPOs As Int16)
        Dim oSubControl As Control
        Dim Field_Name As String
        Dim aRow As DataRow
        Dim aCol As DataColumn
        Dim oTextBox As TextBox
        For Each oSubControl In Form_Name.Controls
            If oSubControl.Controls.Count > 0 Then
                If TypeName(oSubControl) = "TextBox" Then
                    oTextBox = oSubControl
                    aRow = pors.Rows(RowPOs)
                    If oTextBox.Tag <> "" And oTextBox.Tag <> "N" Then
                        Try
                            oTextBox.Text = aRow.Item("" & oTextBox.Tag & "")
                        Catch ex As Exception
                            MsgBox(ex.Message)
                        End Try
                    End If
                End If
            End If
        Next oSubControl
    End Sub
0
 
LVL 1

Author Comment

by:Xavior2K3
ID: 9727287
Thanks for that works like a charm.  I did have to edit it as the first if statment inside the for loop resulted in false so i got rid of it.  What was its purpose?

Thanks
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month17 days, 14 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question