|
|
|
พี่ช่วยดูโค้ด sql นี้หน่อยน่ะค่ะ การเขียนคำสั่ง JOIN เพื่อต้องการ show ข้อมูล โดยการดึงมาจากฐานข้อมูล |
|
|
|
|
|
|
|
Code (VB.NET)
Protected Sub bindShow()
Dim sql As String
Dim dv As DataView
sql = "SELECT tb_ibank_complaint.*,tb_complaint_Title.Detail As DTitle,tb_complaint_occu.Detail As DOccu,tb_complaint_Subject.Detail As DSubject,tb_complaint_Status.Detail As DStatus"
sql += " ,tb_complaint_branch.*,tb_complaint_branch.Detail As DResponder,[ tb_complaint_Khet].Detail As DKhet,tb_complaint_phak.Detail As DPhak"
'sql += " ,tb_complaint_Division.Detail As DDivision"
sql += " FROM tb_ibank_complaint"
sql += " INNER JOIN tb_complaint_Title"
sql += " ON tb_ibank_complaint.title = tb_complaint_Title.Id"
sql += " INNER JOIN tb_complaint_occu"
sql += " ON tb_ibank_complaint.occu = tb_complaint_occu.Id"
sql += " INNER JOIN tb_complaint_Subject"
sql += " ON tb_ibank_complaint.Subject = tb_complaint_Subject.Id"
sql += " INNER JOIN tb_complaint_Status"
sql += " ON tb_ibank_complaint.status = tb_complaint_Status.Id"
sql += " INNER JOIN tb_complaint_branch"
sql += " ON tb_ibank_complaint.responder = tb_complaint_branch.Id"
sql += " INNER JOIN [ tb_complaint_Khet]"
sql += " ON tb_complaint_branch.IdK = [ tb_complaint_Khet].ID"
sql += " INNER JOIN tb_complaint_phak"
sql += " ON tb_complaint_branch.IdP = tb_complaint_phak.Id"
'sql += " INNER JOIN tb_complaint_Answer"
'sql += " ON tb_complaint_branch.IdP = tb_complaint_Answer.Id"
'sql += " INNER JOIN tb_complaint_Division"
'sql += " ON tb_complaint_branch.IdD = tb_complaint_Division.Id"
'sql += " where tb_ibank_complaint.Id = '" & Request.QueryString("LId") & "'"
Response.Write(sql)
dv = ObjDb.GetDataSet(sql).Tables(0).DefaultView
If dv.Count > 0 Then
Me.lbTitle.Text = dv.Item(0)("DTitle").ToString
Me.lbName.Text = dv.Item(0)("Name").ToString
Me.lbLastname.Text = dv.Item(0)("Lastname").ToString
Me.lbOccu.Text = dv.Item(0)("DOccu").ToString
Me.lbIdCard.Text = dv.Item(0)("IdCard").ToString
Me.lbAddress.Text = dv.Item(0)("Address").ToString
Me.lbEmail.Text = dv.Item(0)("Email").ToString
Me.lbContactPhone.Text = dv.Item(0)("ContactPhone").ToString
Me.lbTypeR.Text = dv.Item(0)("TypeR").ToString
Me.lbSubject.Text = dv.Item(0)("DSubject").ToString
Me.lbMessage.Text = dv.Item(0)("Message").ToString
Me.lbKhet.Text = dv.Item(0)("DKhet").ToString
Me.lbPhak.Text = dv.Item(0)("DPhak").ToString
Me.lbStatus.Text = dv.Item(0)("DStatus").ToString
Me.lbResponder.Text = dv.Item(0)("DResponder").ToString
Me.lbComment.Text = dv.Item(0)("Comment").ToString
'Me.lbDivision.Text = dv.Item(0)("DDivision").ToString
'Me.lbCause.Text = dv.Item(0)("Cause").ToString
'Me.lbCorAction.Text = dv.Item(0)("CorAction").ToString
'Me.lbStepsCom.Text = dv.Item(0)("StepsCom").ToString
End If
End Sub
พี่ช่วยดูโค้ด sql นี้หน่อยน่ะค่ะ
จากโค้ดข้างบน
ส่วนที่ comment เป็นที่ส่วนที่ต้องการ JOIN แต่เมื่อพอรัน ไม่ได้error แต่ไม่ขึ้นข้อความรึว่า ไม่แสดง show ขึ้น
Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), VB.NET
|
|
|
|
|
|
Date :
2012-04-26 10:35:46 |
By :
beem |
View :
1004 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่ๆ คนไหนอ่านดูแล้ว ช่วยดูให้หน่อย แล้วตอบให้หน่อยน่ะคะ
|
|
|
|
|
Date :
2012-04-26 10:41:46 |
By :
beem |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เรื่อง Query มันไล่ยากหน่อยน่ะครับ
|
|
|
|
|
Date :
2012-04-26 10:52:52 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอิ่ม
|
|
|
|
|
Date :
2012-04-26 11:09:47 |
By :
beem |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|