web 2.0

How to use ASP & SQL Server Display Multiple Column

How to use ASP & SQL Server Display Multiple Column This is tutorial asp developers how to using ASP list data from SQL Server table and display result of multiple column.

ShotDev Focus:
- ASP & SQL Server list data and multiple column.

Example

asp_sqlserver_column.asp


<% Option Explicit %>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<%
Dim Conn,strSQL,objRec,intRows
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=localhost;Database=mydatabase;UID=sa;PWD=;"

strSQL = "SELECT * FROM gallery "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3

Response.Write("<table border='0' cellspacing='1' cellpadding='1'><tr>")

intRows = 0

While Not objRec.EOF
intRows = intRows + 1
Response.Write("<td>")
%>
<center>
<img src="shotdev/<%=objRec.Fields("Picture").Value%>"><br>
<%=objRec.Fields("GalleryName").Value%>
<br>
</center>
<%
Response.Write("</td>")
If intRows Mod 2 = 0 Then
Response.Write("</tr>")
End If

objRec.MoveNext
Wend
Response.Write("</tr></table>")

objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
</body>
</html>

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_sqlserver_column.asp

Screenshot

ASP & SQL Server (Display Multiple Column)
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.