Results 1 to 9 of 9

Thread: [RESOLVED] Am I going about this all wrong?

Threaded View

  1. #1

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Resolved [RESOLVED] Am I going about this all wrong?

    I am moving systems from VB6 to VS2008. I am trying to do things in the "NET" way. On this particular form I had a FlexGrid. I entered an employee number and it went to the time card database and filled the grid with the employee's punches. In 2008 there is no Flexgrid. I have a data grid. I use a reader to get the employee information and another reader to get the time card data. What i don't get is how to fill the cells/rows in the data grid. Do I use the sql statement in the 2nd read as the data source for the datagrid? Or, am I just using VB 2008 to write VB6 code?

    Code:
    Dim reader As SqlDataReader
                Dim sql As New SqlClient.SqlCommand("SELECT * From EMPFILE WHERE [EMPNUM] = " & CInt(txtEmpNumber.Text))
                sql.Connection = cnxntech
                sql.CommandType = CommandType.Text
                reader = sql.ExecuteReader
                Using reader
                    If reader.HasRows Then
                        lblEmpName.Text = reader("NAMEF") & " " & reader("NAMEL")
                        lblEmpName.Refresh()
                        '
                        '------------------------------------------------------------
                        ' get time card data
                        '------------------------------------------------------------
                        '
                        Dim reader1 As SqlDataReader
                        Dim sql1 As New SqlClient.SqlCommand("SELECT * From TIMECARDS WHERE [EMPNUM] = " & CInt(txtEmpNumber.Text) & " ORDER BY [PAYDATE] DESC, [SHIFTDATE] DESC")
                        sql1.Connection = cnxntech
                        sql1.CommandType = CommandType.Text
                        reader1 = sql1.ExecuteReader
                        Using reader1
                            If reader1.HasRows Then
                                While reader1.Read
                                    '-------must figure out how to get to columns
                                End While
                            End If
                        End Using
                        sql1.Dispose()
                        reader1.Close()
                        '===============
                    End If
                End Using
    Any guidance will be appreciated as I will be using the same sort of processing in many places withing this app.
    Last edited by Pasvorto; Dec 21st, 2010 at 09:29 AM.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width