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?
Any guidance will be appreciated as I will be using the same sort of processing in many places withing this app.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




Reply With Quote