Using ADO to Connect to a Database and Retrieve the Contents of a Table [ASP Programming] Home » ASP » ASP Using Database Table Definitions: Table Name[MusicTable.mdb]-Download Primary KeyMusicID Foreign KeyNil Column Definition: Column NameData Type MusicIDAutoNumber MusicNameText SingerNameText PageLinkText LyricsText Table Description: Column NameDescription MusicIDCreate AutoNumber for music id MusicNameinsert text SingerNameinsert text PageLinkinsert text Lyricsinsert text <%@Language=VBScript%> <%Option Explicit %> Using ADO to Connect to a Database and Retrieve the Contents of a Table MusicID MusicName SingerName Lyrics <% Dim objConn Set objConn=Server.CreateObject("ADODB.Connection") objConn.Provider="Microsoft.Jet.OLEDB.4.0" objConn.Open "d:\ASP-Database.mdb" 'Create a recordset object instance and retrieve the information fromt the MusicTable table. Dim objRS, mySQL 'set query to open records from MusicTable mySQL="SELECT * FROM MusicTable order by MusicID asc" Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open mySQL, objConn WHILE NOT objRS.EOF MusicID = objRS("MusicID") MusicName = objRS("MusicName") SingerName = objRS("SingerName") PageLink = objRS("PageLink") Lyrics = objRS("Lyrics") Lyrics = Left(Lyrics, 70) %> <%=MusicID%> <%=MusicName%> <%=SingerName%> <%=Lyrics%>... <% objRS.MoveNext WEND %> Download Complete Source Below Figure shows the output of above asp code, when viewed through a browser. Share on Facebook Share on Twitter Share on Google Plus RELATED POSTS