|
 |
|
ต้องการค้นหาแบบมีเงื่อนไงโดยใช้ DropDownList จะต้องเขียนอย่างไรคะ ตัวอย่างดังรูป.. |
|
 |
|
|
 |
 |
|
ต้องการค้นหาแบบมีเงื่อนไงโดยใช้ DropDownList จะต้องเขียนอย่างไรคะ ตัวอย่างดังรูป..
และให้แสดงข้อมูลที่ต้องการดังนี้คะ
รหัสสินค้า
ชื่อสินค้า
กลุ่มสินค้า
รุ่น

Code (VB.NET)
Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
Dim strSQL As String = "select aa.GoodCode," & _
"aa.GoodName1," & _
"bb.GoodCateCode+' '+bb.GoodCateName GoodCate," & _
"cc.GoodGroupCode+' '+cc.GoodGroupName GoodGroup," & _
"dd.GoodPattnCode+' '+dd.GoodPattnName GoodPattn," & _
"ee.GoodBrandName," & _
"ff.Remark(GoodModel)" & _
"from EMGood aa ," & _
"EMGoodCate bb ," & _
"EMGoodGroup cc ," & _
"EMGoodPattn dd ," & _
"EMGoodBrand ee ," & _
"EMGoodRemarkHD ff" & _
"where"
Select Case ddlGroupBy.SelectedValue
Case 1
' Case 1 ค้นหาด้วยรหัสสินค้า
strSQL = strSQL & "aa.GoodCode LIKE '%" & txtTag.Text & "%'"
Case 2
' Case 2 ค้นหาด้วยชื่อ
strSQL = strSQL & "aa.GoodName1 LIKE '%" & txtTag.Text & "%'"
End Select
Dim da As New SqlDataAdapter(strSQL, condb)
da.Fill(ds, "select")
dt = ds.Tables("select").Rows(0)
lblName.Text = dt("GoodName1")
lblProductCode.Text = dt("GoodCode")
lblGroup.Text = dt("GoodGroupCode")
lblDesign.Text = dt("GoodPattnCode")
lblBrand.Text = dt("GoodBrandName")
lblModel.Text = dt("GoodModel")
Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), VB.NET

|
|
 |
 |
 |
 |
Date :
2011-08-22 14:48:13 |
By :
chokul |
View :
1190 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็เกือบถูกแล้วน่ะครับแต่คุณควรจะเว้น space แต่ล่ะ บรรทัดด้วยครับ เพราะ string มันจะต่อกันยาวเลย ทำให้ผิด Statement
Code (VB.NET)
Dim strSQL As String = " select aa.GoodCode, " & _
" aa.GoodName1," & _
" bb.GoodCateCode+' '+bb.GoodCateName GoodCate, " & _
" cc.GoodGroupCode+' '+cc.GoodGroupName GoodGroup, " & _
" dd.GoodPattnCode+' '+dd.GoodPattnName GoodPattn, " & _
" ee.GoodBrandName, " & _
" ff.Remark(GoodModel) " & _
" from EMGood aa , " & _
" EMGoodCate bb , " & _
" EMGoodGroup cc , " & _
" EMGoodPattn dd , " & _
" EMGoodBrand ee , " & _
" EMGoodRemarkHD ff " & _
" where"
Select Case ddlGroupBy.SelectedValue
Case 1
' Case 1 ค้นหาด้วยรหัสสินค้า
strSQL = strSQL & " aa.GoodCode LIKE '%" & txtTag.Text & "%' "
Case 2
' Case 2 ค้นหาด้วยชื่อ
strSQL = strSQL & " aa.GoodName1 LIKE '%" & txtTag.Text & "%' "
End Select
|
 |
 |
 |
 |
Date :
2011-08-22 18:47:25 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|