Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help, Cannot UPDATE

Status
Not open for further replies.

knight1001

Technical User
Nov 29, 2004
14
GB
Hello i've been trying to Update access db inputs but i just can't get it to update.

Theres no errors it just won't work

Code:
private void Update_Click(object sender, EventArgs e)
{
  if (Page.IsValid)
  {

  commandpartthree = new OleDbCommand("UPDATE Cars SET [Car No] = @CarNo, [Team Name] = @TeamName, [Factory Date] = @FactoryDate, [Engine Make] = @EngineMake, [Main Sponsor] = @MainSponsor WHERE = [CarNo], @CarNumDrop");
  commandpartthree.Connection = connectionpartthree;

  commandpartthree.Parameters.Add("@CarNo",OleDbType.VarChar);
  commandpartthree.Parameters["@CarNo"].Value = TextCarNo.Text;
  
  commandpartthree.Parameters.Add("@TeamName", OleDbType.VarChar);
  commandpartthree.Parameters["@TeamName"].Value = TextTeamName.Text;

  commandpartthree.Parameters.Add("@FactoryDate", OleDbType.VarChar)
  commandpartthree.Parameters["@FactoryDate"].Value = TextFactory.Text;
  
  commandpartthree.Parameters.Add("@EngineMake", OleDbType.VarChar);
  commandpartthree.Parameters["@EngineMake"].Value = TextEngine.Text;
   
  commandpartthree.Parameters.Add("@MainSponsor", OleDbType.VarChar);
  commandpartthree.Parameters["@MainSponsor"].Value = TextMain.Text;
  
  
 }
 }
 
How about:
commandpartthree.ExecuteNonQuery();
 
cheers for the reply but still dosen't work.

would it help if i placed the whole script up?
 
Maybe. Are you getting and error? Have you wired up this Update_Click method to a Button (if not that will cause nothing to happen also)?
 
I think so lol

<asp:button CssClass="controlText" Width="60" ID="Update" Text="Update" runat="server"/>

cheers
 
doesn't this usually need someting added like this

private void Update_Click(object sender, EventArgs e)
Handles Update.Click{


or is that a vb only thing?

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
There should be a handler in InitializeComponent:
private void InitializeComponent()
{
this.Update.Click += new System.EventHandler(this.Update_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top