Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

asp.net beginner needs a help !

jzhou819jzhou819 Posts: 18Member
Hi, I created a page to populate data from an Access database. Everything looks fine except the page is blank. What am I missing? See the code below. default.aspx.vb
[code]
Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strconnection As String
Dim cn As New OleDbConnection
strconnection = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("app_dataforms.mdb")
cn.ConnectionString = strconnection
cn.Open()
Dim cm As New OleDbCommand
cm.CommandText = "select * from forms"
cm.CommandType = Data.CommandType.Text
cm.Connection = cn
Dim dr As OleDbDataReader
dr = cm.ExecuteReader
While dr.Read
Dim trrow As New HtmlTableRow
Dim tddata As HtmlTableCell
tddata = New HtmlTableCell
tddata.InnerHtml = dr("form_path").ToString
trrow.Cells.Add(tddata)
tddata = New HtmlTableCell
tddata.InnerHtml = dr("form_name").ToString
trrow.Cells.Add(tddata)
tddata = New HtmlTableCell
tddata.InnerHtml = dr("Form_wordpath").ToString
trrow.Cells.Add(tddata)


End While
cn.Close()
End Sub
End Class
[/code]
How come when I run the code, it opens a blank page? Do I need any control in the default.aspx page? Thanks for your help in advance!


Comments

  • iwilld0itiwilld0it Posts: 1,134Member
    Looks like u are not adding the table rows to the table control ...

    Anyways, I would bind the data to a control such as the Repeater, DataList, or DataGrid.

    : Hi, I created a page to populate data from an Access database. Everything looks fine except the page is blank. What am I missing? See the code below. default.aspx.vb
    : [code]
    : Imports System.Data.OleDb
    : Partial Class _Default
    : Inherits System.Web.UI.Page
    :
    : Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    : Dim strconnection As String
    : Dim cn As New OleDbConnection
    : strconnection = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("app_dataforms.mdb")
    : cn.ConnectionString = strconnection
    : cn.Open()
    : Dim cm As New OleDbCommand
    : cm.CommandText = "select * from forms"
    : cm.CommandType = Data.CommandType.Text
    : cm.Connection = cn
    : Dim dr As OleDbDataReader
    : dr = cm.ExecuteReader
    : While dr.Read
    : Dim trrow As New HtmlTableRow
    : Dim tddata As HtmlTableCell
    : tddata = New HtmlTableCell
    : tddata.InnerHtml = dr("form_path").ToString
    : trrow.Cells.Add(tddata)
    : tddata = New HtmlTableCell
    : tddata.InnerHtml = dr("form_name").ToString
    : trrow.Cells.Add(tddata)
    : tddata = New HtmlTableCell
    : tddata.InnerHtml = dr("Form_wordpath").ToString
    : trrow.Cells.Add(tddata)
    :
    :
    : End While
    : cn.Close()
    : End Sub
    : End Class
    : [/code]
    : How come when I run the code, it opens a blank page? Do I need any control in the default.aspx page? Thanks for your help in advance!
    :
    :
    :

  • abhisaabhisa Posts: 1Member
    hi

    i know this is a very late reply but i thought it may b helpful for you

    the only thing missing in your code is HtmlTable(or)if it is added in design mode..the mistake is you are not adding the rows to the table.

    ok

    have a nice time bye




  • jzhou819jzhou819 Posts: 18Member
    Thank you very much!

    : hi
    :
    : i know this is a very late reply but i thought it may b helpful for you
    :
    : the only thing missing in your code is HtmlTable(or)if it is added in design mode..the mistake is you are not adding the rows to the table.
    :
    : ok
    :
    : have a nice time bye
    :
    :
    :
    :
    :

Sign In or Register to comment.