Question

  • Creator
    Topic
  • #2174410

    Search code usig vb.net(2008) & SQL Dbase

    Locked

    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

All Answers

  • Author
    Replies
    • #2849852

      Clarifications

      by smd&ms ·

      In reply to Search code usig vb.net(2008) & SQL Dbase

      Clarifications

    • #2888934

      Need further clues their matey

      by tony hopkinson ·

      In reply to Search code usig vb.net(2008) & SQL Dbase

      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.

    • #2890040

      Too many answers to this but here is a simple approach

      by mydiab ·

      In reply to Search code usig vb.net(2008) & SQL Dbase

      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.

Viewing 2 reply threads