4 Replies - 828 Views - Last Post: 29 September 2012 - 09:09 PM Rate Topic: -----

#1 xhanemila4  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 29-September 12

Requery every button press

Posted 29 September 2012 - 01:17 PM

Hi I'm kinda new in using vb.net so please bare with me. Ok for the topic im trying to do is requery a search to populate the labels every time I press the button1 but it only happen when i first search is null or No record found, but when i search once and found a data then populate the label and search again it doesn't show in label. If i seem vague on my explanation, Sorry. What ever comments I get I will take it as a stepping stone, Thank You guys.

    Public Sub btnSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSet.Click


        If txtBarcodeID.Text <> "" Then
            ds.Clear()
            ds.Tables.Clear()
            lblFName.Text = ""
            lblLName.Text = ""
            lblMName.Text = ""
            lblTimeIn.Text = ""
            lblCourse.Text = ""
            lblStudentNumber.Text = ""



            connectToDatabase()
            openConnection()

            sqlcommandViewStudentByBCN()
            adapter.Fill(ds)
            display(ds)
        Else
            txtBarcodeID.Clear()
            txtBarcodeID.Focus()

        End If

    End Sub

    Sub display(ByVal ds As DataSet)

        Try

            Dim dataTable As DataTable = ds.Tables(0)

            If dataTable.Rows.Count <> 0 Then
                lblNoRecord.Visible = False
                lblStudentNumber.Text = Convert.ToString(dataTable.Rows(0)(1))
                lblLName.Text = Convert.ToString(dataTable.Rows(0)(2))
                lblFName.Text = Convert.ToString(dataTable.Rows(0)(3))
                lblMName.Text = Convert.ToString(dataTable.Rows(0)(4))
                lblCourse.Text = Convert.ToString(dataTable.Rows(0)(5))
                lblTimeIn.Text = time
            Else
                lblNoRecord.Text = "No Record Found! "
            End If


        Catch ex As Exception
            lblNoRecord.Text = "no Record Found! "
        End Try

    End Sub






 


Is This A Good Question/Topic? 0
  • +

Replies To: Requery every button press

#2 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Requery every button press

Posted 29 September 2012 - 01:27 PM

You do realize, that you are reloading everything from database on each button click, and this is not really effective. Once you have non 0 row count in display method, you "turn off" your lblNoRecord, and never make it visible again. Is that your only problem?

This post has been edited by lucky3: 29 September 2012 - 01:29 PM

Was This Post Helpful? 1
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1055
  • View blog
  • Posts: 4,087
  • Joined: 02-July 08

Re: Requery every button press

Posted 29 September 2012 - 04:12 PM

This is where the Entity Framework excels. It loads the whole database, then you can make your queries with LINQ or lambda statements based on some filter or criteria and show those queries.
Was This Post Helpful? 0
  • +
  • -

#4 xhanemila4  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 29-September 12

Re: Requery every button press

Posted 29 September 2012 - 09:00 PM

View Postlucky3, on 29 September 2012 - 01:27 PM, said:

You do realize, that you are reloading everything from database on each button click, and this is not really effective. Once you have non 0 row count in display method, you "turn off" your lblNoRecord, and never make it visible again. Is that your only problem?


Hi lucky3, Yay tried to make lblNoRecord to visible never saw that really heheh, about the reloading of everything its a monitoring system on every click of button it will query , the truth is its not finally done i will going to add more statement I tried once but the data gets mix up i will post the whole code if I cant get it :) ty again

View Post_HAWK_, on 29 September 2012 - 04:12 PM, said:

This is where the Entity Framework excels. It loads the whole database, then you can make your queries with LINQ or lambda statements based on some filter or criteria and show those queries.



Hi _Hawk_, I'm sticking on the plan is thats the syntax i can understand even a little . But Thank you too _Hawk_ :)
Was This Post Helpful? 0
  • +
  • -

#5 xhanemila4  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 29-September 12

Re: Requery every button press

Posted 29 September 2012 - 09:09 PM

View Postxhanemila4, on 29 September 2012 - 09:00 PM, said:

View Postlucky3, on 29 September 2012 - 01:27 PM, said:

You do realize, that you are reloading everything from database on each button click, and this is not really effective. Once you have non 0 row count in display method, you "turn off" your lblNoRecord, and never make it visible again. Is that your only problem?
Hi lucky3, Yay tried to make lblNoRecord to visible never saw that really heheh, about the reloading of everything its a monitoring system on every click of button it will query , the truth is its not finally done i will going to add more statement I tried once but the data gets mix up i will post the whole code if I cant get it :) ty again

View Post_HAWK_, on 29 September 2012 - 04:12 PM, said:

This is where the Entity Framework excels. It loads the whole database, then you can make your queries with LINQ or lambda statements based on some filter or criteria and show those queries.
Hi _Hawk_, I'm sticking on the plan because its the syntax i can understand even a little . But Thank you too _Hawk_ :)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1