How can we load multiple tables in a Dataset?
How can we load multiple tables in a Dataset
Hi,
How can we load multiple tables in a Dataset?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Aug 5, 2011, 8:58 AM EDT
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
con.Open()
str = "select * from student;select * from customer;select * from product"
com = New SqlCommand(str, con)
sqlda = New SqlDataAdapter(com)
ds = New DataSet
sqlda.SelectCommand.CommandText = str
sqlda.Fill(ds)
DataGrid1.DataSource = ds
End Sub
End ClassMayur DigheRank #1,078 · 1.8K reputationPosted Aug 4, 2011, 10:18 PM EDT
http://www.vbdotnetheaven.com/UploadFile/ea36c5/5812
Mayur DigheRank #1,078 · 1.8K reputationPosted Aug 6, 2011, 8:26 AM EDT
if you want to take All Data From 3 Different Tables you must load them individual into dataset using adaptor.
i think in each of table (Student, Customer, Product) have a Primary Key then you can assign a common name to it
e.g.
1.select StudId AS ID form Student
2.select CustID as ID from Customer etc..
after loading each table(supposed named as 'Information') into dataset you will get single column of ID into DataTable and not 3 separate columns for separate tables...
You CAN achieve the intended result doing like this.....
Read More about.. Transaction-SQL especailly Select Clause
Eddie JackRank #2,520 · 556 reputationPosted Aug 7, 2011, 11:29 PM EDT