reading through the sql database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jarremw
    New Member
    • Jan 2008
    • 50

    reading through the sql database

    hello all,
    i am making my own blogging type page with aspx, what im wanting to do is display all the posts in the table(i have a title column and a entry column) on a page, but i want the post to be separated, i know im not explaining very well, but what i mean is i want the format to be like title post -seaparation- title post-separation- title post, so you can distinguish between each post, i have been working with vb for some time, but this is my first venture into asp.

    thanks
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi jarremw,

    Can you confirm whether you're using ASP.NET or Classic ASP please?

    Thanks,

    Dr B

    Comment

    • jarremw
      New Member
      • Jan 2008
      • 50

      #3
      sorry its asp.net that comes with visual studio 2005
      Last edited by DrBunchman; Apr 24 '08, 05:43 PM. Reason: Moved to .NET - ASP forum for Classic ASP only

      Comment

      • deric
        New Member
        • Dec 2007
        • 92

        #4
        Are you using some control like datagrid or something?
        Your example ("title post -seaparation- title post-separation- title post") will be in one line/row only or each post is displayed in one row with separator?

        I can understand you better if you can provide a sample data and your expected output... and the code (where you're having trouble) that you have so far.

        Comment

        • jarremw
          New Member
          • Jan 2008
          • 50

          #5
          i dont have any sample code, i honestly dont know where to start with it , but my wanted output is something like a blog system, i want to display the title,date, entry and author all in a nice formatted way while grabbing it from mysql, i just dont know how to set it up so that it will loop through the enitre database and display all of that info, can this be done through asp? i know this is possible through php but i like asp better, im not using a datagrid or anything like that....here is what i want the output to look like

          title
          date
          entry
          author

          start over with the same format after each row

          Comment

          • deric
            New Member
            • Dec 2007
            • 92

            #6
            Yes, this can be done but not with ASP alone.
            ASP.NET is a server-scripting language that can communicate with your server. The two of its important uses are:
            - access your database and return the results to a browser,
            - respond to user's query submitted through HTML forms.
            So, you need another language, like VB.NET/C#, to handle the other needed functionalities (like displaying the returned result of database query) of your web application.

            Well, I assume you know how to code VB.NET, ASP.NET, SQL, and HTML, cause I will just give you a prototype and will leave the rest of the coding to you.

            I will use SQLDataReader for this example. You can use other ways if you'd like. It would be like this somehow:
            Code:
            <%
            Dim querystring = "Select title, date, entry, author from yourTable"
            Dim connection As New SQLConnection(connectionString) 'Provide the connection string to your database
            Dim command As New SQLCommand(querystring, connection)
            
            connection.Open()
            
            Dim reader As SQLDataReader = command.EXecuteReader()
            %>
            
            <HTML>
            <HEAD><TITLE>Blog Posts</TITLE></HEAD>
            <BODY>
            <% 
               If reader.HasRows = False Then
                     Response.Write("No data retrieved.")
               Else
            %>
               <TABLE>
               <% While Reader.Read() %>
                  <TR>
                     <TD>Title<TD>
                     <TD><% Response.Write(reader(0)) %><TD>
                  </TR>
                  <TR>
                     <TD>Date<TD>
                     <TD><% Response.Write(reader(1)) %><TD>
                  </TR>
                  <TR>
                     <TD>Entry<TD>
                     <TD><% Response.Write(reader(2)) %><TD>
                  </TR>
                  <TR>
                     <TD>Author<TD>
                     <TD><% Response.Write(reader(3)) %><TD>
                  </TR>
               <% End While 
                  reader.Close()
               %>
               </TABLE>
            <% End If%>
            </BODY>
            </HTML>
            There are actually several ways to achieve this.
            You can read this helpful site to learn the basics and more of the languages you'd like to use.

            Comment

            • jarremw
              New Member
              • Jan 2008
              • 50

              #7
              thank you so much! that was exactly what i was looking for, i started playing around with it more and got some really good results, probably my new favorite language!

              Thanks!

              Comment

              • deric
                New Member
                • Dec 2007
                • 92

                #8
                that's good.. cheers!
                enjoy coding.

                Comment

                Working...