how to fill DataAdapter when two tables are being used+ASP.Net
-
i am providing the code below string strcon = "Provider=SQLOLEDB;Server=(local);Database=rescue15;uid=sa;pwd=sasa;"; OleDbConnection conn = new OleDbConnection(strcon); string q = "SELECT crime_mgmt.cr_location 'Crime Location',crime_mgmt.cr_date,offensive_issue.c_desc FROM crime_mgmt,offensive_issue"; OleDbCommand cmd = new OleDbCommand(q, conn); conn.Open(); DataSet ds = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter(cmd); da.Fill(ds, "offensive_issue"); da.Fill(ds, "crime_mgmt");
-
i am providing the code below string strcon = "Provider=SQLOLEDB;Server=(local);Database=rescue15;uid=sa;pwd=sasa;"; OleDbConnection conn = new OleDbConnection(strcon); string q = "SELECT crime_mgmt.cr_location 'Crime Location',crime_mgmt.cr_date,offensive_issue.c_desc FROM crime_mgmt,offensive_issue"; OleDbCommand cmd = new OleDbCommand(q, conn); conn.Open(); DataSet ds = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter(cmd); da.Fill(ds, "offensive_issue"); da.Fill(ds, "crime_mgmt");
Just wrote one line instead of two... then, you will get the all records from both tables.
mavii wrote:
da.Fill(ds, "bothtable");
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) "Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."