Results 1 to 6 of 6

Thread: how do i load data into an unbound datagridview

  1. #1
    Join Date
    Feb 2009
    Posts
    96

    how do i load data into an unbound datagridview

    how do i load data from a table into an unbound datagridview. All the research i've done 99% of doesnt show how to load from a table all it shows is how to add fields or information manually.
    Example:
    if i have form 1 with employee data and a employee table i use the id of the employee to search payroll records and only display that employees payroll record(s) on a 2nd form which is an unbound datagridview. The payroll records are also in a table... Can some one show code that would be similar to this.. and where would i put this said code---- Yeah I know I'm a noob but we all start somewhere.

  2. #2
    Join Date
    Mar 2008
    Posts
    258

    Re: how do i load data into an unbound datagridview

    To illustrate how to load MySQL data into the DataGridView control a simple VB.NET 2008 project was developed (Figure 1). As you can see, the form contains a DataGridView control with ten columns and two groups of bound and unbound data load buttons (Load 1 and Load 2). Both groups show the execution time in seconds (s) for 20,000 records of MySQL data load.

    Figure 1: Bound and unbound DataGridView control project


    look at the code of the buttons Load 1 (bound mode) and Load 2 (unbound mode). Listing 2 shows the click event code of the bound Load 1 button. The Using statement creates and destroys the instance of a class UnboundClass (Listing 3). The ADO.NET Connection String mMySQLConnectionString has been passed as a constructor to the class. Just a reminder that this Connection String value is defined and stored in the app.config file as I explained in the article "Define and Store MySQL ADO Connection String in VB.NET 2005". The procedure BoundDataLoading() (Listing 4) is called to load the data. The DataGridView UnboundDataGridView and the TexBox RecordCountTextBox are passed by reference. These procedures is showing below.
    Code:
    Private Sub BoundLoadButton_Click(ByVal sender As System.Object, 
                                      ByVal e As System.EventArgs) 
                                      Handles BoundLoadButton.Click
         swatch.Reset()
         swatch.Start()
         Cursor = Cursors.WaitCursor
         Try
            Using BoundObject As New UnboundClass(mMySQLConnectionString)
               Call BoundObject.BoundDataLoading(UnboundDataGridView, _
                                                 RecordCountTextBox, _
                                                 mErrorMsgString)
               If Not IsNothing(mErrorMsgString) Then
                  Cursor = Cursors.Default
                  MessageBox.Show(mErrorMsgString, _
                                  Me.Text, _
                                  MessageBoxButtons.OK, _
                                  MessageBoxIcon.Error)
               End If
            End Using
         Catch exError As Exception
            MessageBox.Show(exError.Message, _
                            Me.Text, _
                            MessageBoxButtons.OK, _
                            MessageBoxIcon.Error)
         End Try
         Cursor = Cursors.Default
         swatch.Stop()
         mTimeDouble = swatch.ElapsedMilliseconds * 0.001
         BoundTimeTextBox.Text = mTimeDouble.ToString
    End Sub

  3. #3
    Join Date
    Apr 2008
    Posts
    1,948

    Re: how do i load data into an unbound datagridview

    Private Sub BoundLoadButton_Click(ByVal sender As System.Object,
    ByVal e As System.EventArgs)
    Handles BoundLoadButton.Click
    swatch.Reset()
    swatch.Start()
    Cursor = Cursors.WaitCursor
    Try
    Using BoundObject As New UnboundClass(mMySQLConnectionString)
    Call BoundObject.BoundDataLoading(UnboundDataGridView, _
    RecordCountTextBox, _
    mErrorMsgString)
    If Not IsNothing(mErrorMsgString) Then
    Cursor = Cursors.Default
    MessageBox.Show(mErrorMsgString, _
    Me.Text, _
    MessageBoxButtons.OK, _
    MessageBoxIcon.Error)
    End If
    End Using
    Catch exError As Exception
    MessageBox.Show(exError.Message, _
    Me.Text, _
    MessageBoxButtons.OK, _
    MessageBoxIcon.Error)
    End Try
    Cursor = Cursors.Default
    swatch.Stop()
    mTimeDouble = swatch.ElapsedMilliseconds * 0.001
    BoundTimeTextBox.Text = mTimeDouble.ToString
    End Sub

  4. #4
    Join Date
    Feb 2009
    Posts
    96

    Re: how do i load data into an unbound datagridview

    ty for the try but once again that just shows how to show info on the same form as the button--- i have 2 forms and my 2nd form is NOT bound to the 1st form. the 1st form has all the bound information to the employees but the payroll itself is NOT bound. I need to search the employee records and on selecting the employee a 2nd form opens showing the payroll--- 2 forms in total not one-- the above code only works for single form apps. reason is the sql string doesnt carry to the 2nd form

  5. #5
    Join Date
    Feb 2009
    Posts
    133

    Re: how do i load data into an unbound datagridview

    Hi, Daren!
    I think this is what you need to look for loading data to an unbound datagrid view!
    http://dev.mysql.com/tech-resources/...t.html#Unbound
    AND
    http://www.evisualwww.com/downloads/...plications.pdf
    I hope this helps you loading data to your unbound datagrid in the second form

    Just a question - Why do you want this second form? (Is it important?)
    Last edited by madjack; 03-03-2009 at 02:11 PM.
    IF YOU CAN'T Convince THEM ...

    CONFUSE THEM ...

  6. #6
    Join Date
    Feb 2009
    Posts
    96

    Re: how do i load data into an unbound datagridview

    yeah madjack its for a school project--- they state it must be on a second form

Similar Threads

  1. How to auto load Meta data from Amazon?
    By Tinku-Jia in forum Windows Software
    Replies: 4
    Last Post: 22-02-2012, 10:00 PM
  2. Unbound Sprint and Aim in Serious Sam 3: BFE
    By Akshey in forum Video Games
    Replies: 9
    Last Post: 26-11-2011, 12:05 PM
  3. Value in unbound text box in DB restore
    By Devabrata in forum Software Development
    Replies: 6
    Last Post: 11-01-2011, 07:21 PM
  4. Flash Lite 3.1 Unable to load data dilemma
    By Harmony60 in forum Portable Devices
    Replies: 4
    Last Post: 20-04-2010, 03:00 PM
  5. Line Rider 2: Unbound game application issue
    By Kaufman in forum Video Games
    Replies: 5
    Last Post: 30-03-2010, 05:40 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,718,102,441.13900 seconds with 16 queries