|
|
|
สอบถามหน่อยคับ คือ ผมจะสร้าง dropdownlist แล้วจะดึงข้อมูล จาก database มาใช้อะคับ |
|
|
|
|
|
|
|
Code (ASP)
<select name="myName">
<%
Dim Conn,strSQL,objRec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("mydatabase.mdb"),"" , ""
strSQL = "SELECT * FROM customer "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
%>
<%
While Not objRec.EOF
%>
<option value="<%=objRec.Fields("CustomerID").Value%>"><%=objRec.Fields("Name").Value%></option>
<%
objRec.MoveNext
Wend
%>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
</select>
ASP & Dropdownlist
ASP Microsoft Access List Record
|
|
|
|
|
Date :
2009-11-24 23:17:47 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมใช้เชื่อมต่อกับ sql นะคับ
|
|
|
|
|
Date :
2009-11-24 23:52:29 |
By :
k |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string strConn;
strConn = " Data Source= CODENAME\\SQLEXPRESS ;Database=master; User ID=sa;Password=12345";
SqlConnection Conn = new SqlConnection(strConn);
Conn.Open();
string sqlUserName;
sqlUserName = "SELECT UserName FROM Customer";
SqlCommand com = new SqlCommand(sqlUserName, Conn);
DropDownList4.DataTextField = "UserName";
DropDownList4.DataValueField = "CustomerID";
DropDownList4.DataBind();
ลองใช้วิธีนี้แล้วไม่ออก อะคับ
|
|
|
|
|
Date :
2009-11-24 23:53:28 |
By :
k |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|