0 Replies - 849 Views - Last Post: 10 March 2013 - 09:25 AM Rate Topic: -----

#1 Pooja Mengaji   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 24-February 13

can databindings be created for diff tables ?

Posted 10 March 2013 - 09:25 AM

i hav a form Order...its link wid the database is done by 3 tables Customer,design & order tables. wat i want wen the from is loaded for the 1st time, using databindings the contents for the reqired fields shuld be loaded automatically..but the problem is how do i connect 3 diff binding sources with a single datagridview...i know to bind using a single table...heres the code how i bind for single table for customer form..:
 Public WithEvents suppsource As BindingSource
    Dim ds As DataSet

    Private Sub viewall_supp()
            Me.DataGridView1.AllowUserToAddRows = False
            Dim con As New OracleConnection("User Id=shweja;Password=shweja")
            Dim adp As OracleDataAdapter
            Dim ds As DataSet
            Dim cmd As New OracleCommand
            adp = New OracleDataAdapter
            ds = New DataSet
            adp.SelectCommand = New OracleCommand
            adp.SelectCommand.Connection = con
            adp.SelectCommand.CommandText = "select * from supplier"
            ds = New DataSet
            adp.Fill(ds, "supplier")
            DataGridView1.DataSource = ds.Tables(0)
            cmd.Connection = con
            cmd.CommandText = "select count(*) from supplier"
            Dim I As Integer
            I = cmd.ExecuteScalar()
            rec.Text = I
            suppsource = New BindingSource(ds, "supplier")
            suppsource.Sort = "sid"
            DataGridView1.DataSource = suppsource
            txtcid.DataBindings.Add("Text", suppsource, "Sid")
            nm.DataBindings.Add("Text", suppsource, "Name")
            snm.DataBindings.Add("Text", suppsource, "Surname")
            cn1.DataBindings.Add("Text", suppsource, "ContactNo1")
            cn2.DataBindings.Add("Text", suppsource, "ContactNo2")
            cn3.DataBindings.Add("Text", suppsource, "ContactNo3")
            cn4.DataBindings.Add("Text", suppsource, "ContactNo4")
        Catch ex As Exception
        End Try
    End Sub

this code fills the textboxes wen form loaded....my order form shud work in a similar manner...
the create query fro customer,design & order are:
create table customer(custId int primary key,Name varchar(30),Surname varchar(30),Address varchar(50), mobNo int, landNo int);
create table Design(desgId int primary key, design_type varchar(30) not null, image_name varchar(20) not null,image_path varchar(300) not null,Gold_KT int not null,Weight number(4,2) not null, Quantity int not null, MakingCharges number(8,2) not null);
create table orderform(OrderId int , Cid int, OrderDate date not null ,DelDate date not null, DesignType varchar(40) not null ,DesgName varchar(50),DesignId int, Tid int unique,PriceBef number(8,2) not null, TotalPrice number(8,2) ,Vat number(4,2) not null, Finalprice number(8,2) not null, depAmt number(8,2), remAmt number(8,2) , primary key(OrderId), foreign key(DesignId) references Design, foreign key(Cid) references Customer);

im not able to attach apic of my order form so not able to explain wat fields i want...please ask me if u dont understand anything...

This post has been edited by Pooja Mengaji: 10 March 2013 - 09:28 AM

Is This A Good Question/Topic? 0
  • +

Page 1 of 1