Question

Locked

Search code usig vb.net(200 & SQL Dbase

By smd&ms ·
I am working on my school project using vb.net and SQL. But I am having problems coding for the Next, Previous and the Search buttons

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Need further clues their matey

by Tony Hopkinson In reply to Search code usig vb.net(2 ...

the BindingNavigator component (it in the Data section of the toolbox) is teh tool of choice cookie cutter wise, pop one on, set it to the same datasource as your grid? and Bob is your mother's sister's brother.

Search is a tad more complicated.
If you want to search in the data you have that's driving the grid, this should help

http://www.programmersheaven.com/mb/VBNET/293286/293286/find-data-in-data-table/

if you mean search as in query out the data from sql server to poulate the grid, that's a whole 'nother ball game.

Collapse -

Too many answers to this but here is a simple approach

by MyDIAB In reply to Search code usig vb.net(2 ...

Let us assume you are using text boxes and by pushing the next and previous button you will move throught an array of previously built records maybe from a database select. Remember this is a simple solution a bound dataset would be what you shooting for. first you will need a structure as

Private Structure Config
Dim ServerName As String
Dim DBName As String
Dim FileSize As String
End Structure

next you will need to bind the structure to a array as in
Dim strArray(1) As Config

Add a varible to maintain a key or bookmark of the current record in the array
Dim strArrayCurrentKey As Int16

next you will add you next and previous buttons to the form and add some code to each as shown below.

Private Sub CmdNextRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdNextRecord.Click
strArrayCurrentKey = strArrayCurrentKey + 1
If strArrayCurrentKey > UBound(strArray, 1) Then
strArrayCurrentKey = UBound(strArray, 1)
End If
Call LoadNewRecord()
End Sub

Private Sub CmdLastRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdLastRecord.Click
strArrayCurrentKey = UBound(strArray, 1)
Call LoadNewRecord()
End Sub

Now you will need a sub to load the textboxes

Private Sub LoadNewRecord()
TxtServer.Text = strArray(strArrayCurrentKey).ServerName
TxtDBName.Text = strArray(strArrayCurrentKey).DBname
TxtFileSize.Text = strArray(strArrayCurrentKey).FileSize
End Sub

The textboxes will now change by pressing the next and Previous buttons.

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums