SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict jlisec01's Avatar
    Join Date
    Nov 2006
    Location
    MI
    Posts
    326
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Tring to relocate my results

    Hello there, I had problems with my code, basically when you click the get data button, the list of names in the database will display on the same screen, but I can't get the results of all the names to display where I want, for instance in a table at the bottom of the page, any help? I really appreciate it, you all helped me out before and I can't thank you enough.

    Code VBNET:
    <%@ Import Namespace="System.Data.OleDb" %>
     
    <html>
    <head>
    <title>Sample Page using VB</title>
    <script runat="server" language="VB">
    Sub getData(s As Object, e As EventArgs)
    	Dim objConn As OleDbConnection
    	Dim objCmd As OleDbCommand
    	Dim objRdr As OleDbDataReader
     
    	objConn = New
            OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" &server.mappath("CollegeDB.mdb"))
    	objCmd = New OleDbCommand("SELECT * FROM Employees", objConn)
    	objConn.Open()
    	objRdr = objCmd.ExecuteReader()
    	While objRdr.Read()
    		Response.Write(objRdr.Item("Name") & "<br />")
    	End While
    	objRdr.Close()
    	objConn.Close()
    End Sub
    </script>
    </head>
    <body>
    <form runat="server">
      <asp:Button id="btnSubmit" OnClick="getData" Text="Get Data" runat="server" />
    </form>
    </body>
    </html>

  2. #2
    SitePoint Zealot iScrawl's Avatar
    Join Date
    Mar 2009
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Instead of:
    Code:
    Response.Write(objRdr.Item("Name") & "<br />")
    Declare a variable in the beginning of the function (let's call it tmp1), and do:
    Code:
    tmp1 = temp1 & "<TR><TD>" & (objRdr.Item("Name")) & "</td></tr>"
    Hanan Moiseyev
    Online games and Videos - http://www.playwithroger.com
    Share your art - http://www.iscrawl.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •