simple postback to a database

R

Ray Valenti

In a .Net Asp application I am able to retrieve data from an Access db and
display in on a web form. How ever during the update function after a page
update, the update command does not throw an exception but it does not save
out the changes either. It seems that upon the postback no data exists in
the dataset. I must be missing something.

How you post the data from an edited user page back to the database?


if (!(Page.IsPostBack))
{
this.oleDbDAUser.Fill(this.dsMain1,"Users");
this.lblUserID.DataBind();
this.txtFirstName.DataBind();
this.txtMiddleName.DataBind();

..........

}



No error here, but no data is saved either:


private void btnSave_Click(object sender, System.EventArgs e)
{
try
{
this.oleDbDAUser.Update(this.dsMain1);
}
catch (Exception oops)
{
this.txtUserMessage.Text = "Error occured!<BR>" + oops.ToString() ;
}

}
}

Thanks,
Ray
 
C

Craig Deelsnyder

Ray said:
In a .Net Asp application I am able to retrieve data from an Access db and
display in on a web form. How ever during the update function after a page
update, the update command does not throw an exception but it does not save
out the changes either. It seems that upon the postback no data exists in
the dataset. I must be missing something.

How you post the data from an edited user page back to the database?


if (!(Page.IsPostBack))
{
this.oleDbDAUser.Fill(this.dsMain1,"Users");
this.lblUserID.DataBind();
this.txtFirstName.DataBind();
this.txtMiddleName.DataBind();

.........

}



No error here, but no data is saved either:


private void btnSave_Click(object sender, System.EventArgs e)
{
try
{
this.oleDbDAUser.Update(this.dsMain1);
}
catch (Exception oops)
{
this.txtUserMessage.Text = "Error occured!<BR>" + oops.ToString() ;
}

}
}

Thanks,
Ray

the dataset is not persisted between requests. The web is stateless, so
unless you store values in some persistent storage (such as Session or
ViewState to name a couple), that dataset is not there the second time
around (or unless you repopulate it).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top