shers -2 Junior Poster

Hi,

I'm working on VB.NET Express and SQL Server Express. I have a DataGridView control in the form, with 8 columns, of which one column, which has default values, is hidden and one column is already filled with default values. I want to populate the DataGridView with records that exists in the database by selecting the record, based on the conditions in the SQL statement. And the record should be displayed in order of the hidden column values, without disturbing the default value column that is not hidden. How can I accomplish this? I have done some code, but it is not working. Here it is:

Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        'bolOpen = True

        Dim strProj As String
        strProj = LV.SelectedItems(0).Text
        Dim strItem(2) As String
        strItem = strProj.Split("-")

        With EntryFrm
            .txtRFS.Text = strItem(0)
            .txtPName.Text = strItem(1)
        End With

        Dim strCon As String = My.Settings.ConnectString
        Dim sqlConn As New SqlConnection(strCon)
        Dim Cmd As SqlCommand

        Dim DeptID As Integer

        DeptID = cboDept.SelectedIndex.ToString + 1

        Cmd = New SqlCommand("SELECT SDATE, EDATE, TLHRS, PHRS, THRS, COMP FROM PDETAILS WHERE RFS = " & strItem(0) & _
        " AND DEPTID = " & DeptID & " ORDER BY PHASEID", sqlConn)

        Dim DA As SqlDataAdapter
        Dim DS As New DataSet

        DA = New SqlDataAdapter(Cmd)
        DS = New DataSet

        DA.Fill(DS, "PDetails")

        EntryFrm.DGV.DataSource = DS
        EntryFrm.DGV.DataMember = "PDetails"

        Me.Close()

    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.