i want to combine the tables and getting their data and structure?

Posted by Sudheep.grandhe under Sql Server on 12/8/2011 | Points: 10 | Views : 1053 | Status : [Member] | Replies : 4
Hi,


i am having the tables like tbl_report1,tbl_report2 .i combine these two tables and retrieve the data and structure into tbl_customer.but it shows the error.
tbl_report1 columns:
invoiceno(fk),orderno,paritculars,quantity,perprice,amount,invoicedate,ondate,compname

tbl_report2 columns:
compname,compaddress,invoiceno(pk),orderno,invoicedate,ondate,amountstatus,netamount,netvat,tamount

tbl_company columns-custid(pk),custname,custaddress,custstate,custcity,custstdcode,custphoneno,custmobilno
i want to combine above both tables and getting data and structure into tbl_customer.how can i wrote the query for the above tables.please do the needful.

Best,
Sudheep.



Responses

Posted by: Alok on: 12/9/2011 [Member] Starter | Points: 25

Up
0
Down
You should use datarelation using dataset.......

Thanks & Regards,
Alokssm

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 12/9/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for replying to me.can you please explain the process for combining the tables with their data and structure.actually i have a combobox.if i selected any value from the combo box it has to display the remaining textbox values.this is my requirment.Here is my code.please do the needful.


public partial class UpdateCustomerInvoice : Form
{
public UpdateCustomerInvoice()
{
InitializeComponent();
}
string str;
SqlConnection con;
SqlDataAdapter da;
DataSet ds;
DataSet ds1;
private void UpdateCustomerInvoice_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=marsweb;integrated security=true");
SqlCommand cmd = new SqlCommand("select custname,custaddress from tbl_customer", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataRow row in ds.Tables[0].Rows)
{
cmb_customername.Items.Add(row.ItemArray[0].ToString());
}
con.Close();
}

private void cmb_customername_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=marsweb;integrated security=true");
con.Open();
SqlCommand cmd = new SqlCommand("select custname,custaddress from tbl_customer", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds );
DataRow trow;
ds.Tables[0].PrimaryKey = (new DataColumn[]{
ds .Tables [0].Columns [0]});
trow = ds.Tables[0].Rows.Find(cmb_customername.Text);
txt_customeraddress.Text = trow["custaddress"].ToString();
}
}
}
with this code i can display only customer address.But,i need to display invoiceno,orderno,ondate,invoicedate,particulars,quantity,perprice,amount,netamount,netvat,tamount etc...with the help of combobox selected value.but,it wont shows the remaining.For that reason i want to combine those tables.in this regarding you can help me please.if you want any doubt please let me know.



Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bryan48 on: 12/11/2011 [Member] Starter | Points: 25

Up
0
Down
Good day! I have a little knowledge of vb but sad to say that I was not practiced it. So I forgot on how to perform it and I'm sorry if I can't answer your problem.

Regards,
[url=http://www.theinterviewscience.com] books on interviewing [/url]

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 12/11/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
Create a two data sets and use "Merge" Method .

Note: Column counts should be same.


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response