Thursday, July 9, 2009

HOw to populate a drop-down box from sql server using asp script for dynamic web page?

I am creating a dynamic web page for that I need to populate a drop-down box from a table in sql server. Can somebody please write the code in asp script?

HOw to populate a drop-down box from sql server using asp script for dynamic web page?
Try this:


%26lt;%


Set conn=Server.CreateObject("ADODB.Connecti...


conn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;PersistSecurity Info=False;Initial Catalog=sqldatabase;Data Source=sqlsource"


set rs=Server.CreateObject("ADODB.Recordset"...


%%26gt;


%26lt;select name="selectbox" size="1"%26gt;


%26lt;%


rs.Open "Select column From table",conn


Do Until rs.EOF


%%26gt;


%26lt;option value="%26lt;%=rs("column")%%26gt;"%26gt;%26lt;%=rs("column"...


%26lt;%


rs.MoveNext


Loop


%%26gt;


No comments:

Post a Comment