hello sir ,
Q:-How to display data in datagrid from multiple tables in SQL server 2000 and vb.net 2003
its very imp for my project
i have tried with following code
Pl tell me the correct way to do it
tables i am using are
TABLES COLUMN CONSTRAINTS COLUMN NAMES
t_candidates reg_no primary key , f_name ,email_id
t_additioinalinfo reg_no foreign key , cat_id foreign key
t_category cat_id primary key category (this column ontains actual category values)
t_result reg_no foreign key, rc_name ,salary
Dim ds As DataSet
ds = New DataSet
Dim objshortlistedresume As New frmshortlisted
Dim str As String
Try
str = "select reg_no,category,rc_name from t_candidates" & _
"Join t_result on t_candidates.reg_no=t_result.reg_no" & _
"join t_additionalinfo on t_category.cat_id =t_additionalinfo.cat_id" & _
"join t_additionalinfo on t_result.reg_no=t_additionalinfo.reg_no"
Catch exp As SqlException
MsgBox(exp.Message, MsgBoxStyle.Critical, "SQL error")
Catch exp As Exception
MsgBox(exp.Message, MsgBoxStyle.Critical, "General error")
End Try
Dim mydataadapter As SqlDataAdapter = New SqlDataAdapter(strshortlisted, myconn)
mydataadapter.SelectCommand = New SqlCommand
mydataadapter.SelectCommand.Connection = myconn
mydataadapter.SelectCommand.CommandText = str
mydataadapter.SelectCommand.CommandType = CommandType.Text
Try
myconn.Open()
mydataadapter.SelectCommand.ExecuteNonQuery()
mydataadapter.Fill(ds, "t_candidates")
myconn.Close()
' dv = New DataView(ds.Tables("t_candidates"))
objshortlistedresume.dg_shortlisted.DataSource = ds
objshortlistedresume.dg_shortlisted.DataMember = "t_candidates"
Catch exp As SqlException
MsgBox(exp.Message, MsgBoxStyle.Critical, "SQL error")
Catch exp As Exception
MsgBox(exp.Message, MsgBoxStyle.Critical, "General error")
End Try
objshortlistedresume.Show()
Me.Hide()