Dataset showing inconsistent results

Last post 02-27-2007 12:34 AM by c.ratnakar. 4 replies.

Sort Posts:

  • Dataset showing inconsistent results

    02-22-2007, 9:29 AM
    • Loading...
    • wibblet
    • Joined on 01-20-2007, 4:31 PM
    • London
    • Posts 22

    This is a tricky one.

     

    I created a dataset using the designer, to produce a data table for use in a report.  The query selects a student's name and other details based on a parameter, their student ID.

     

    I tested the results in the designer, using one student's ID.  Everything worked fine.  However, later when I tried to create reports using this data, I only got static data, i.e. only the data that was present in the database when I created the dataset, no updated data showed.  I've been tearing my hair out about this (see previous posts) so I tested the data set again.  Weirdly, when I use the first student's ID, the dataset works fine (though still static data), however, when I tested it with another student's ID I got no results at all, not even their name.  I know the ID is correct, so can anyone shed any light on what is going on here?

     

    p.s. please don't tell me I have to recreate the thing from scratch, it was a devil to get working in the first place. [frustrated emoticon]

  • Re: Dataset showing inconsistent results

    02-22-2007, 10:42 AM
    • Loading...
    • jdingo
    • Joined on 01-03-2007, 2:28 PM
    • Posts 340
    wibblet, can you post some code maybe...?
    If my post is helpful please mark as answer
    Regards -- jp
    (http://www.rzrsolutions.com/rzrWeb20/BlogViewScreen.aspx)
  • Re: Dataset showing inconsistent results

    02-23-2007, 5:59 AM
    • Loading...
    • wibblet
    • Joined on 01-20-2007, 4:31 PM
    • London
    • Posts 22

    The problem definitely seems to be the dataset.  I've checked the configuration and it seems to be OK, using the connection string in the webconfig that all the other datasets use.  The SQL is:

    SELECT tblstudent.FirstName, tblstudent.Surname, tblincident.Incident_ID, tblincident.Student_Id, tblincident.Min_late, tblincident.Min_early, tblincident.Mob, tblincident.mus, tblincident.hw, tblincident.prep, tblincident.interr, tblincident.disrupt, tblincident.behav, tblincident.Incidentdate
    FROM (tblstudent INNER JOIN tblincident ON tblstudent.StudentID = tblincident.Student_Id)
    WHERE tblincident.Student_Id = Parastudent

     

    Where the parameter Parastudent is equal to the student ID passed on a query string.  The parameter does not use the @ notation because this is an Access database.  This form of parameter naming works everywhere else I've used it, so I don't think that's the issue.  The problem is, that as the student name is coming from the student table, and all other data from the incident table, if there is no data on the incident table, there should at least be the student name returned.  This simply is not happening when I test it.  Even for students who have incidents recorded, it seems somewhat random as to whether or not the query returns any data.

  • Re: Dataset showing inconsistent results

    02-23-2007, 6:49 AM
    • Loading...
    • wibblet
    • Joined on 01-20-2007, 4:31 PM
    • London
    • Posts 22

    OK, so working backwards, I think I've found the source of the problem and i'm sure it must be easy enough to fix.

     

    When adding data to the incident table, the final part of the code looks like this:

    //Create the command builder

    OleDbCommandBuilder cb = new OleDbCommandBuilder(adaptor);

    //retrieve an updated table adaptor

    adaptor = cb.DataAdapter;

    //update the database using the dataset

    con.Open();

     

    //Response.Redirect("Finishrecord.aspx");

    added = adaptor.Update(dsIncident,

    "tblincident");

    Response.Write(added.ToString() +

    " records added");

    }

    catch (Exception err)

    {

    Response.Write(

    "Error adding record");

    Response.Write(err.Message);

    }

    finally

    {

    con.Close();

    }

     

    I put this line in

    Response.Write(added.ToString() + " records added");

    In the development phase, to check the database was updating.  What I really want to happen is to redirect to another page, hence the commented out

    Response.Redirect("Finishrecord.aspx");

    What appears to be happening is as soon as I put this line in, the database ceases to update, hence the static data etc.  So I've fiddled around with where this line should go, but nothing seems to work.  I'm sure it's simple enough, but I'm just not seeing it.

     Please could somebody point out to me where I'm being such an idiot?

     

  • Re: Dataset showing inconsistent results

    02-27-2007, 12:34 AM
    Answer
    • Loading...
    • c.ratnakar
    • Joined on 11-19-2006, 6:21 AM
    • Hyderabad,India.
    • Posts 43

    Hi wibblet ,

    jus before ur going to select  a new id of a student then before the dataset is going to filled jus clear the dataset and then fill it i hope that would be more helpfull and u can do it like dis

    dataset ds = new dataset();

    ds.clear();

    //neccessary code;

    the fill the dataset thats it and it works pretty well

     

    Thanx if was helpfull,

    with regards,

    Rutts.

     

    Ratnakar Choudry,

    c.ratnakar@gmail.com,

    Tension Nahi Leneka Apun Hai Nah...
Page 1 of 1 (5 items)
Microsoft Communities
Page view counter