Hi all,
I have a problem in my application(vb.net 2005 + oracle).Please try to solve it,if anybody can.
I have a combobox in my winform and a datagrid view.
I need to populate my datagrid on the bases of item selected in combobox.
but somehow I'm not getting any data to appear in my datagrid.
Here is my code and form-->
Imports System.Data
Imports System.Data.OracleClient
PublicClass frmProductsByCustomers
Dim con AsNew OracleClient.OracleConnection
Dim ds AsNew DataSet
Dim da1 As OracleClient.OracleDataAdapter
Dim da2 As OracleClient.OracleDataAdapter
Dim sql1 AsString
Dim sql2 AsString
PrivateSub frmProductsByCustomers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
con.ConnectionString = "Data Source=Parv;Persist Security Info=True;User ID=project;Password=project;Unicode=True"
con.Open()
sql1 = "SELECT customer_name from customer_t"
sql2 = "SELECT product_t.product_ID,product_t.product_description,product_t.product_finish FROM customer_t,product_t,order_t,order_line_t WHERE customer_t.customer_id = order_t.customer_id AND order_t.order_id = order_line_t.order_id AND product_t.product_id = order_line_t.product_id AND customer_name = ' " & cboCustomer.SelectedItem & " ' "
da1 = New OracleClient.OracleDataAdapter(sql1, con)
da2 = New OracleClient.OracleDataAdapter(Sql2, con)
da1.Fill(ds, "customer_t")
da2.Fill(ds, "product_t")
con.Close()
Dim MaxCustomerRows AsInteger
Dim inc AsInteger
MaxCustomerRows = ds.Tables("customer_t").Rows.Count
For inc = 0 To MaxCustomerRows - 1
cboCustomer.Items.Add(ds.Tables("customer_t").Rows(inc).Item(0))
Next
grdProductsByCustomers.DataSource = ds
grdProductsByCustomers.DataMember = "product_t"
EndSub
PrivateSub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
If MessageBox.Show("Are you sure you want to close this form??", "Products by Customers Form", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.OK Then
Me.Close()
EndIf
EndSub
EndClass
I have a problem in my application(vb.net 2005 + oracle).Please try to solve it,if anybody can.
I have a combobox in my winform and a datagrid view.
I need to populate my datagrid on the bases of item selected in combobox.
but somehow I'm not getting any data to appear in my datagrid.
Here is my code and form-->
Imports System.Data
Imports System.Data.OracleClient
PublicClass frmProductsByCustomers
Dim con AsNew OracleClient.OracleConnection
Dim ds AsNew DataSet
Dim da1 As OracleClient.OracleDataAdapter
Dim da2 As OracleClient.OracleDataAdapter
Dim sql1 AsString
Dim sql2 AsString
PrivateSub frmProductsByCustomers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
con.ConnectionString = "Data Source=Parv;Persist Security Info=True;User ID=project;Password=project;Unicode=True"
con.Open()
sql1 = "SELECT customer_name from customer_t"
sql2 = "SELECT product_t.product_ID,product_t.product_description,product_t.product_finish FROM customer_t,product_t,order_t,order_line_t WHERE customer_t.customer_id = order_t.customer_id AND order_t.order_id = order_line_t.order_id AND product_t.product_id = order_line_t.product_id AND customer_name = ' " & cboCustomer.SelectedItem & " ' "
da1 = New OracleClient.OracleDataAdapter(sql1, con)
da2 = New OracleClient.OracleDataAdapter(Sql2, con)
da1.Fill(ds, "customer_t")
da2.Fill(ds, "product_t")
con.Close()
Dim MaxCustomerRows AsInteger
Dim inc AsInteger
MaxCustomerRows = ds.Tables("customer_t").Rows.Count
For inc = 0 To MaxCustomerRows - 1
cboCustomer.Items.Add(ds.Tables("customer_t").Rows(inc).Item(0))
Next
grdProductsByCustomers.DataSource = ds
grdProductsByCustomers.DataMember = "product_t"
EndSub
PrivateSub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
If MessageBox.Show("Are you sure you want to close this form??", "Products by Customers Form", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.OK Then
Me.Close()
EndIf
EndSub
EndClass
Attachments
Last edited: