 |
|
VB.NET ช่วยดูให้ทีครับ ในการดึงค่ามาแสดงจากฐานข้อมูลที่ยังไม่ได้ทำการขาย....มือใหม่ครับ |
|
 |
|
|
 |
 |
|


คือในการขายของผม ต้องการค่าเฉพาะ ค่า546 กับ 6765 มาแสดง เพราะว่า ค่า 6737 ได้ทำการขายไปแล้ว
ช่วยดู โค้ดให้ที ครับ
Code (VB.NET)
Private Sub cb_product_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_product.SelectedIndexChanged
Dim da As SqlDataAdapter
Dim ds As DataSet = New DataSet
Dim dt As New DataTable
Dim sqlcommand As String
sqlcommand = "SELECT product.pro_name,product.amount,product.price,serial.serial_number,status_product.product_ids FROM product INNER JOIN serial ON (product.pro_id = serial.product_id) INNER JOIN status_product ON product.pro_id = status_product.product_ids where statuss = 1 and product.pro_id = '" & cb_product.Text & "'"
da = New SqlClient.SqlDataAdapter(sqlcommand, SqlConnection1)
da.Fill(dt)
open_conn()
If dt.Rows.Count > 0 Then
txt_name.Text = dt.Rows(0)("pro_name")
txt_serial.Text = dt.Rows(0)("serial_number")
txt_price.Text = dt.Rows(0)("price")
txt_amount.Text = dt.Rows(0)("amount")
End If
End Sub
Tag : ASP.NET, Ms SQL Server 2005, Ms SQL Server 2008, VBScript, VB.NET, VS 2008 (.NET 3.x)
|
|
 |
 |
 |
 |
Date :
2012-03-13 16:40:34 |
By :
evolution99 |
View :
1306 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ท่านก็เพิ่มเงื่อนไขตรง SQL ต่อท้ายเป็น AND statuss = 1 (จากที่ผมดู 1=ยังไม่ได้ขาย 0 เท่ากับขายเเล้ว)
เท่านี้อันอื่นก็คงพอเข้าใจนะ
|
 |
 |
 |
 |
Date :
2012-03-13 19:23:21 |
By :
Cyg |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อื่ม แปลกดี
1. ลองดูนะครับ ไม่แน่ใจว่าค่าใน statuss ของคุณเป็น text หรือ int ถ้าเป็น text ลองใส่ '.....' ค่อมดู
2. ไม่แน่ใจว่ามี field statuss มากกว่า 1 ที่รึป่าว(ปกติมันจะ Error) ลองใส่ชื่อ table ข้างหน้าดูครับ
3. SQL อาจ Join ไม่ถูก ผมว่าลองเอาวงเล็บตรง (product.pro_id = serial.product_id) ออก
ลองดูครับ
|
 |
 |
 |
 |
Date :
2012-03-15 15:07:47 |
By :
Amee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|