I have two tables


tb_Rnd1

RndId(Pk) RndWood Rndlength RndWindth RndPNo RndConst RndCft

Tb_Rnd2
RndId(Fk) RndDate RndName RndTCft RndRCft RndTotalAmt


If I click btn_Add

Insert Records like this first


RndId(Pk) RndWood Rndlength RndWindth RndPNo RndConst RndCft
1 Teakwood 23 12 1 144
X


Tb_Rnd2
RndId(Fk) RndDate RndName RndTCft RndRCft RndTotalAmt
1 23/3/2011 asd


And ten I add detail and click btn_Add


RndId(Pk) RndWood Rndlength RndWindth RndPNo RndConst RndCft
1 Teakwood 23 12 1 144
X

1 Teakwood 45 34 2 120 Z=Y+X

Tb_Rnd2
RndId(Fk) RndDate RndName RndTCft RndRCft RndTotalAmt
1 23/3/2011 asd z 21 R value


This Detalis will be display list view
Like this

Rndlength RndWindth RndPNo RndConst RndCft
45 34 2 120 Z
23 12 1 144 X


Tb_Rnd2
RndDate RndName RndWood RndTCft RndRCft RndTotalAmt
23/3/2011 asd Teak Wood Z 21 R value


I want how will i write codings in C#


Advanced Thanks

dear whats the main question you are asking ? do you want to know how to add record in database through c#? or any thing else.
If you are asking queries then it will be very simple insert query

//connection class
SqlDataAdapter myDataAdapter = new SqlDataAdapter();
        private void Form1_Load(object sender, EventArgs e)
        {

            myDataSet = new DataSet();
  string connection = @"DATA_SOURCE";
            SqlConnection cn = new SqlConnection(connection);
            try
            {
                cn.Open();
            }
            catch (Exception)
            {
                MessageBox.Show("Did not connect");
            }
           //for first table
 string strSQL = "INSERT INTO TABLE_1(Rndlength, RndWindth, RndPN, RndConst, RndCft) VALUES( 45, 34 ,2 ,120 ,Z)";
            myDataAdapter = new System.Data.SqlClient.SqlDataAdapter(strSQL, cn);
//for second table
 strSQL = "INSERT INTO TABLE_2(RndDate, RndName, RndWood ,RndTCft, RndRCft, RndTotalAmt) VALUES( '23/3/2011', 'asd' ,'Teak Wood', 'Z', 21, 'R' ,'value')";
            myDataAdapter = new System.Data.SqlClient.SqlDataAdapter(strSQL, cn);
        }
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.