'i am trying to get f_name + m_name + l_name three diferent columns combined from data grid view on cell content click into combobox.

Private Sub bugdgv_CellContentDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles bugdgv.CellContentDoubleClick
        Dim row As Integer = bugdgv.CurrentCell.RowIndex
        frmbug.bugcmbdeliver.Items.Clear()
        Try
            obcon.cmd.CommandText = "select d.del_name from deliver_project d,bug b where b.bug_id=d.del_id and d.del_name='" & bugdgv.Item("del_name", row).Value & "'"
            obcon.con.Open()
            Dim dr As SqlDataReader
            dr = obcon.cmd.ExecuteReader
            If (dr.Read) Then
                frmbug.bugcmbdeliver.Items.Add(0)
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            obcon.con.Close()
        End Try
        frmbug.bugcmbassign.Items.Clear()
        Try
            'obcon.cmd.CommandText = "select c.f_name from deliver_project d,bug b where b.bug_id=d.del_id and d.del_name='" & bugdgv.Item("del_name", row).Value & "'"
            obcon.cmd.CommandText = "select c.f_name + ' '+ c.l_name as 'name' from contact c,bug b where b.con_id=d.con_id and d.f_name + ' ' + d.l_name='" & bugdgv.Item("f_name + ' ' + l_name", row).Value
            obcon.con.Open()
            Dim dr As SqlDataReader
            dr = obcon.cmd.ExecuteReader
            If (dr.Read) Then
                frmbug.bugcmbassign.Items.Add(0)
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            obcon.con.Close()
        End Try
        frmmain.BugsToolStripMenuItem_Click(sender, e)
        frmbug.bugbtnedit.Show()
        frmmain.bugs.bid = bugdgv.Item("bug_id", row).Value
        frmmain.bugs.bugtxtname.Text = bugdgv.Item("bug_name", row).Value
        frmmain.bugs.bugrtbdescription.Text = bugdgv.Item("bug_descrip", row).Value
        frmmain.bugs.bugcmbdeliver.Text = bugdgv.Item("del_name", row).Value
        'frmmain.bugs.bugcmbassign.Text = bugdgv.Item("f_name", row).Value
        'frmmain.bugs.bugcmbassign.Text = bugdgv.Item("l_name", row).Value
        frmmain.bugs.bugcmbstatus.Text = bugdgv.Item("bug_status", row).Value
        frmmain.bugs.bugdtpdate.Text = bugdgv.Item("bug_date", row).Value
        frmmain.bugs.bugtxtprojnm.Text = bugdgv.Item("bug_p_name", row).Value
        frmmain.bugs.bugtxtwork.Text = bugdgv.Item("bug_name", row).Value
        Me.Close()
end sub

Recommended Answers

All 6 Replies

You use an inner join to combine two tables. A very good explanation of joins (inner and outer) with clear examples can be found here

sorry i can get your point , you want to show 3 columns in grid like this f_name + m_name + l_name in a single cell , ? and 2nd thing what i understand is that you want to show 3 columns of your grid in a combo in this way f_name + m_name + l_name ,
please rephrase you question.

Regards

As w says, the more info the better. It would help if you could tell us the table structures and (in English) what data you wan to display as in (for example)

I want to display the employee ID and name for every employee who has sold more than 8 cars in the given month (which would require a join of the employee table and the sales table).

sorry i can get your point , you want to show 3 columns in grid like this f_name + m_name + l_name in a single cell , ? and 2nd thing what i understand is that you want to show 3 columns of your grid in a combo in this way f_name + m_name + l_name ,
please rephrase you question.

Regards

'ya sir i want to show 3 columns of my grid in a combo box on clicking on raw.cellcontent click.

Reread my last post.

Reread my last post.

' Here we r geting data from contact tabel.in a grid view and associate it with specific bug.

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.