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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Aug 5, 2011, 12:58 PM
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 ClassEddie JackPosted Aug 8, 2011, 3:29 AM
Mayur DighePosted Aug 6, 2011, 12:26 PM
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
Mayur DighePosted Aug 5, 2011, 2:18 AM
http://www.vbdotnetheaven.com/UploadFile/ea36c5/5812