 |
|
ต้องการดึงข้อมูลจาก MS SQL 3คอลั่ม มาแสดง ใน Drop drow list ทำยังไง |
|
 |
|
|
 |
 |
|
Code (VB.NET)
strcmd = "select ID+' '+NAME+' '+LASTNAME as newfield from users"
...
...
ddlcostcen.DataTextField = ("newfield")
น่าจะประมาณนี้ครับ
|
ประวัติการแก้ไข 2010-09-03 16:51:07
 |
 |
 |
 |
Date :
2010-09-03 16:50:39 |
By :
tee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Sub ShowName()
Dim objconn As SqlConnection
Dim objcmd As SqlCommand
Dim objReader As SqlDataReader
Dim strconn As String
Dim strcmd As String
strconn = ConfigurationManager.AppSettings("ConnectionString")
objconn = New SqlConnection(strconn)
objconn.Open()
strcmd = "select ID,NAME,LASTNAME from USERS"
objcmd = New SqlCommand(strcmd, objconn)
objReader = objcmd.ExecuteReader()
While objReader.Read()
ddlcostcen.Items.Add(New ListItem(String.Format("{0} {1} {2}", objReader("ID").ToString(), objReader("NAME").ToString(), objReader("LASTNAME").ToString()), objReader("ID").ToString()))
End While
objconn.Close()
End Sub
อืม ทำใน query ง่ายกว่าเนอะ คิดไม่ถึงๆ
|
ประวัติการแก้ไข 2010-09-03 17:01:39
 |
 |
 |
 |
Date :
2010-09-03 16:59:23 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณท่าน tee และ ท่าน tungman มากๆเลยนะครับ ทำได้เรียบร้อยแล้วครับ ใช่วิธีของท่าน tee ครับ 
เพิ่งรู้ว่า Query ทำอะไรได้เยอะแยะเลยครับ 
|
 |
 |
 |
 |
Date :
2010-09-03 17:35:49 |
By :
thecroy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|