simple postback to a database

  • Thread starter Thread starter Ray Valenti
  • Start date Start date
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
 
1) Jet is not designed to be used under IIS.
2) If you ignore 1 proceed at your own risk.
3) When you execute UPDATE against a JET it updates the cache and queues the
write which is only executed if JET goes idle. (See 1).

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Bill,

My ISP supports the use of Jet and it has worked well for years at a
low volume site at least. I had to reload the dataset after the edit,
populate it with the new data, and use the OleDbCommandBuilder object to
prepare the Data Adapter to perform the update.

It was more work that I expected with the bound fields, I was hoping some
magic would happen and this would be done by C# or ASP.Net.

Thanks,
Ray
---------------------------------------------

this.oleDbDAUser.SelectCommand.CommandText = sqlUser();
this.oleDbDAUser.Fill(this.dsMain1,"Users");
OleDbCommandBuilder objBuilder =null;
objBuilder = new OleDbCommandBuilder(this.oleDbDAUser);
this.oleDbDAUser.UpdateCommand = objBuilder.GetUpdateCommand();
this.dsMain1.Tables["Users"].Rows[0]["FirstName"]=this.txtFirstName.Text;
this.dsMain1.Tables["Users"].Rows[0]["MiddleName"]=this.txtMiddleName.Text;
.....
this.oleDbDAUser.Update(this.dsMain1,"Users");
this.txtUserMessage.Text = "Form saved.";
 
Back
Top