How to display data on ASPX after retrive data from data base

HI people ,

I am not using VS.Net and how can i display the data after retrive it from database?

what should i use?

I tried this and and there is an error
<%#DataBinder.Eval(Container.DataItem, “ProductName”)%>
i tried this also and there is an error:
<%Response.write(Productname)>

my sql is select Productname from Table where ID= 123

Really appreciate it if anyone can help… thanks

You need to tell us the error.
Are you using a SQLDatasource or an ObjectDataSource or building a dataset from a DataAdapter?

Hi Currently ,

I have this:

 Dim connection = New OleDbConnection( _
            "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
                Server.MapPath("database.mdb") & ";")
        Dim sql = "select * from product where Id='" +  "123"  + "'"
        Dim command = New OleDbCommand(sql, connection)
        connection.Open()
        Dim reader = command2.executeReader()
        If reader.hasRows Then
            reader.read()

End If

This is my code… how to display it on aspx page thanks

You should probably try and do some of the tutorials on http://www.asp.net/learn/, that will do wonders for you.

Thanks guru wwb_99,

Well, if someone had introduce me that page one month ago. I would love to go through the website but i got like less than 5 hours before my assignment is dude. i only left this part.

Hope that someone can really help.

Thanks

Dim connection As OleDbConnection = New OleDbConnection( _
            "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
                Server.MapPath("database.mdb") & ";")
Dim sql As String = "select * from product where Id='" +  "123"  + "'"
Dim command As OleDbCommand = New OleDbCommand(sql, connection)
connection.Open()
Dim reader As OleDbDataReader = command2.executeReader()
If reader.hasRows Then
    reader.read()
    Response.Write(reader("ProductName"))
End If

Check this tutorial - http://www.vbdotnetheaven.com/UploadFile/mahesh/OleDbDataReader04232005055323AM/OleDbDataReader.aspx

yup yup i went to that page to learn but it does not teach me how to display the result in between the HTML codes in aspx…

for example:

<table>
<tr>
<td>
’ i want the retrived data to be display here
</td>
</tr>
</table>

Thanks


<table>
    <tr>
        <td>
            <asp:TextBox ID="txtProductName" runat="server" />
        </td>
    </tr>
</table>


Dim connection As OleDbConnection = New OleDbConnection( _
            "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
                Server.MapPath("database.mdb") & ";")
Dim sql As String = "select * from product where Id='" +  "123"  + "'"
Dim command As OleDbCommand = New OleDbCommand(sql, connection)
connection.Open()
Dim reader As OleDbDataReader = command2.executeReader()
If reader.hasRows Then
    reader.read()
    txtProductName.text = reader("ProductName").ToString()
End If

Hope this finally helps

how about if i do not want to display it using textbox , i would like to display it as like - response.write?

Then add a field in your Page class, let’s call it ProductName, then assign the database value to that field in output it in the aspx page with Response.Write

sorry for being a dumb as… HELP! what field? thanks

public partial class _Default Inherits System.Web.UI.Page 
{
    Protected ProductName As String 
    Public Sub Page_Load(sender As Object, e As EventArgs)
        Dim connection As OleDbConnection = New OleDbConnection( _
                "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
                    Server.MapPath("database.mdb") & ";")
        Dim sql As String = "select * from product where Id='" +  "123"  + "'"
        Dim command As OleDbCommand = New OleDbCommand(sql, connection)
        connection.Open()
        Dim reader As OleDbDataReader = command2.executeReader()
        If reader.hasRows Then
            ProductName = reader("ProductName").ToString()
        End If
    End Sub
}

<table>
    <tr>
        <td>
            <% Response.Write(ProductName) %>
        </td>
    </tr>
</table>

Oh GOD GOD! you are awesome! … It worked man… I really owe you man… Thank you so much… I dun know how to thank you…

Yeah thanks alot Mike . God Bless you