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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update

Status
Not open for further replies.

tfstom

Programmer
Sep 28, 2002
190
US
I am having a problem with my adapter.update routine. It is apparently in the INSERT statement (as you can see in the debub message). How do I figure out what the problem is? I can't see the insert statement.

I am able to access the database correctly as I am reading and displaying data from the database before I do the update.

I am trying to update an access database and it is not right protected and all my rights are on.

Here is part of the code:
Code:
Sub PlaceAd
   Row = ClassyDS.Tables("Ads").NewRow
   
   CopyToDS
   Row.Item("Posted") = CDate(Today)
   ClassyDS.Tables("Ads").Rows.Add(Row)
   Adapter.Update(ClassyDS, "Ads")
   PostErrors
End Sub


' Copy the values in the properties of this
' control in the ClassyDS
Private Sub CopyToDS
   Row.Item("Title") = Title
   Row.Item("Description") = Description
   Row.Item("Category") = Category
   Row.Item("Price") = CSng(Price)
   Row.Item("Phone") = Phone
   Row.Item("Email") = Email
   Row.Item("State") = State
   Row.Item("Password") = Password
End Sub

Private Sub PostErrors
   HasErrors = ClassyDS.HasErrors
   If HasErrors Then
      RowError = ClassyDS.Tables("Ads").Rows(0).RowError
   End If
End Sub

Here is the the error I get:
Code:
Server Error in '/' Application.
--------------------------------------------------------------------------------

Syntax error in INSERT INTO statement. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.

Source Error: 


Line 74:    Row.Item("Posted") = CDate(Today)
Line 75:    ClassyDS.Tables("Ads").Rows.Add(Row)
Line 76:    Adapter.Update(ClassyDS, "Ads")
Line 77:    PostErrors
Line 78: End Sub
 

Source File: c:\inetpub\[URL unfurl="true"]wwwroot\classyad.ascx[/URL]    Line: 76 

Stack Trace: 


[OleDbException (0x80040e14): Syntax error in INSERT INTO statement.]
   System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) +1662
   System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) +152
   ASP.ClassyAd_ascx.PlaceAd() in c:\inetpub\[URL unfurl="true"]wwwroot\classyad.ascx:76[/URL]
   ASP.editad_aspx.Submit_Click(Object Sender, EventArgs E) in c:\inetpub\[URL unfurl="true"]wwwroot\editad.aspx:80[/URL]
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1277

Thanks,

Tom.
 
Hi there!
Try:
Code:
Sub PlaceAd
   Dim Row As TableRow
   Row = ClassyDS.Tables("Ads").NewRow
   Row.Item("Title") = Title
   Row.Item("Description") = Description
   Row.Item("Category") = Category
   Row.Item("Price") = CSng(Price)
   Row.Item("Phone") = Phone
   Row.Item("Email") = Email
   Row.Item("State") = State
   Row.Item("Password") = Password
   Row.Item("Posted") = CDate(Today)
   ClassyDS.Tables("Ads").Rows.Add(Row)
   Adapter.Update(ClassyDS, "Ads")
   PostErrors
End Sub

[morning]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top