dbread problem of some sort

Results 1 to 2 of 2

Thread: dbread problem of some sort

  1. #1
    Join Date
    Dec 1969

    Default dbread problem of some sort

    [code language="C#"]<BR>&#060;%@ Page Language="C#" Debug="true" %&#062;<BR>&#060;%@ Import Namespace="System.Data" %&#062;<BR>&#060;%@ Import Namespace="System.Data.OleDb" %&#062;<BR><BR>&#060;script runat=server&#062;<BR><BR>void Page_Load( object s, EventArgs e )<BR>{<BR>OleDbConnection dbconn;<BR>OleDbCommand dbcomm;<BR>OleDbDataReader dbread;<BR>string dog = Session["UserID"].ToString();<BR>double bird = Convert.ToDouble(dog);<BR>dbconn = new OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=C:\trackrecordnew.mdb");<BR>dbconn.Open();< BR>dbcomm = new OleDbCommand( "SELECT * FROM EquityHistory WHERE AccountID =" + bird + " ORDER BY DateID DESC" , dbconn );<BR>dbread=dbcomm.ExecuteReader();<BR><BR>equity history.DataSource=dbread;<BR><BR>equityhistory.Da taBind();<BR>if ( dbread.Read() )<BR>{<BR> Name.Text=dbread["Name"].ToString();<BR>}<BR>dbread.Close();<BR>dbconn.Clo se();<BR> <BR>}<BR><BR> void Signout_Click(Object sender, EventArgs E) {<BR><BR> FormsAuthentication.SignOut();<BR> Response.Redirect("myaccount.aspx");<BR> }<BR>&#060;/Script&#062;<BR>[/code]<BR>when i use this code and a datagrid to display the result, it only shows data with dateid 1-7 and NOT data with dateid 8. when i change it to ORDER BY DATEID ASC it only shows data with dateid 2-8 and NOT dateid 1. but, when i take out the code<BR>[code language="C#"]<BR>if ( dbread.Read() )<BR>{<BR> Name.Text=dbread["Name"].ToString();<BR>}<BR>[/code]<BR>(this code is the take the person&#039;s name from the data and later display it uing asp:label)<BR>Well, when i take it out, all the data shows (dateID&#039;s 1-8 all show nothing is omitted)<BR>the problem is i need to get the name out of the database to display it on top. Does anyone know why this occurs and any possible ways to fix it, thanx!

  2. #2
    Join Date
    Dec 1969

    Default Well, you could get rid of...

    ...that data binding and do it all "manually" with the data reader.<BR><BR>But instead of that, why not just use a little bit of client-side JavaScript to clone the value from the details in the table to the heading?<BR><BR>Sure do miss some of the simplicity of ADO, don&#039;t you?<BR><BR>

Posting Permissions

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