Click here to Skip to main content
15,917,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 4 tables
agent(broker_id,name,place,date,year),
buyer(buyer_id,name)
item(item_id,name,desc)
trans(broker_id,buyer_id,item_id,amt)

now i want to display in 1 form on selection of buyer_id from drop down list,then broker_id from 2nd drp downlist,all fields should show in datagridview.

all fields including broker_id,name,place,date year,buyer_name,item_id,name,desc,amt

please help me. and please in vb.net. only any other language.

i request to all experts

thanks in advance
Posted
Comments
sudeshna from bangkok 20-Jul-13 1:38am    
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim cn As New SqlConnection("Data Source=.\INSTANCE;initial catalog=stamp;user=sa;password=gariahat")
'Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
Dim ds As New DataSet
Dim dt As DataTable




cmd.Connection = cn
cn.Open()

Dim da As New SqlDataAdapter("select * from agent", cn)
dt = New DataTable

ds = New DataSet
da.Fill(ds, "agent")

For i As Integer = 0 To ds.Tables("agent").Rows.Count - 1
If ComboBox1.SelectedItem = ds.Tables("agent").Rows(i).Item("broker_id").ToString() Then

da = New SqlDataAdapter("select a.broker_id, a.name,a.place,a.date,a.year,b.name,c.item_id,c.name,d.amt from agent as a,buyer as b,item as c,trans as d where a.broker_id=d.broker_id and b.buyer_id=d.buyer_id and c.item_id=d.item_id", cn)
dt = New DataTable
da.Fill(dt)
DataGridView1.DataSource = dt
' cn.Close()

End If
Next

cn.Close()


End Sub
End Class
sudeshna from bangkok 29-Jul-13 4:54am    
no response till yet? strange
sudeshna from bangkok 20-Jul-13 1:38am    
this is my code, but no records are displaying in combobox1
sudeshna from bangkok 20-Jul-13 4:05am    
can anyone help me please? no answers? please all experts.
i request you all.
i have always got positive reply from here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900