NEwbie Question: Getting DetailsView to output the Insert/UpdateCommandSQL to screen?

Discussion in 'ASP .Net' started by DC, Sep 12, 2007.

  1. DC

    DC Guest

    Ok so Im getting an

    " 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."

    Question is how do I get the detailsview to output the actual SQL
    staemnet Im trying to execute to screen so I can debug my INSERT and
    UPDATE statements?

    Thanks in advance,
     
    DC, Sep 12, 2007
    #1
    1. Advertising

  2. DC

    New Bee Guest

    Re: NEwbie Question: Getting DetailsView to output the Insert/UpdateCommand SQL to screen?

    you should put your failing code into a try/catch block and then examine the
    ex.message/stack trace. This may give you more information about why the
    code is failing.


    Try

    'Your Code

    Catch ex as exception

    response.write( ex.message )

    End Try



    "DC" <> wrote in message
    news:fc8q8i$6dv$...
    > Ok so Im getting an
    >
    > " 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."
    >
    > Question is how do I get the detailsview to output the actual SQL staemnet
    > Im trying to execute to screen so I can debug my INSERT and UPDATE
    > statements?
    >
    > Thanks in advance,
     
    New Bee, Sep 12, 2007
    #2
    1. Advertising

  3. DC

    DC Guest

    New Bee wrote:
    > you should put your failing code into a try/catch block and then examine the
    > ex.message/stack trace. This may give you more information about why the
    > code is failing.
    >
    >
    > Try
    >
    > 'Your Code
    >
    > Catch ex as exception
    >
    > response.write( ex.message )
    >
    > End Try


    Ok so if my AccessDataSource fro the details is as below I can change
    the InsertComand to

    InsertComand="Try

    INSERT INTO user_table (Image, ID, Title, ForeName, SurName,
    PhoneNo, RoomNo, EMail, Role, Course, Year, Staff, BscInfo, MscInfo,
    Mats, Cracks, HdrBoard, HdrForum, InfoSec, Lab, Media, PhdInfo,
    PhdSuper, Research, Secs, Security, Teapot, UgBoard, UgVis, WWW,
    StartDate, ProbabtionDate, EndDate, RetirementDate, FundingBody,
    ResearchGroup, LineManager, PayCategory, Notes) VALUES (@Image, @ID,
    @Title, @ForeName, @SurName, @PhoneNo, @RoomNo, @EMail, @Role, @Course,
    @Year, @Staff, @BscInfo, @MscInfo @Mats, @Cracks, @HdrBoard, @HdrForum,
    @InfoSec, @Lab, @Media, @PhdInfo, @PhdSuper, @Research, @Secs,
    @Security, @Teapot, @UgBoard, @UgVis, @WWW, @StartDate, @ProbabtionDate,
    @EndDate, @RetirementDate, @FundingBody, @ResearchGroup, @LineManager,
    @PayCategory, @Notes)

    Catch ex as exception

    response.write( ex.message )

    End Try
    "

    Or is this going to throw up an error?


    Here is the current AccessDataSource im using

    <asp:AccessDataSource id="DetailsSource" Runat="Server"
    DataFile="C:\Program Files\Common Files\ODBC\Data Sources\user_info2.mdb"

    SelectCommand="SELECT * FROM user_table WHERE ID = @ID"

    InsertCommand="INSERT INTO user_table (Image, ID, Title, ForeName,
    SurName, PhoneNo, RoomNo, EMail,
    Role, Course, Year, Staff, BscInfo, MscInfo, Mats,
    Cracks, HdrBoard, HdrForum, InfoSec, Lab,
    Media, PhdInfo, PhdSuper, Research, Secs, Security, Teapot, UgBoard,
    UgVis, WWW
    StartDate, ProbabtionDate, EndDate, RetirementDate, FundingBody,
    ResearchGroup, LineManager, PayCategory, Notes) VALUES (@Image, @ID,
    @Title, @ForeName, @SurName,
    @PhoneNo, @RoomNo, @EMail, @Role, @Course, @Year,
    @Staff, @BscInfo, @MscInfo
    @Mats, @Cracks, @HdrBoard, @HdrForum, @InfoSec, @Lab, @Media,
    @PhdInfo, @PhdSuper, @Research, @Secs, @Security, @Teapot, @UgBoard,
    @UgVis, @WWW, @StartDate, @ProbabtionDate, @EndDate, @RetirementDate,
    @FundingBody, @ResearchGroup, @LineManager, @PayCategory, @Notes)"

    UpdateCommand="UPDATE user_table SET ID=@ID, Image=@Image,
    Title=@Title, ForeName=@ForeName, SurName=@SurName,
    PhoneNo=@PhoneNo, RoomNo=@RoomNo, Email=@Email,
    Role=@Role, Course=@Course, Year=@year, Staff=@Staff, BscInfo=@BscInfo,
    MscInfo=@MscInfo, Mats=@Mats, Cracks=@Cracks, HdrBoard=@HdrBoard,
    HdrForum=@HdrForum, InfoSec=@InfoSec,
    Lab=@Lab, Media=@Media, PhdInfo=@PhdInfo, PhdSuper=@PhdSuper,
    Research=@Research, Secs=@Secs,
    Security=@Security, Teapot=@Teapot, UgBoard=@UgBoard, UgVis=@UgVis,
    WWW=@WWW,
    StartDate=@StartDate, ProbabtionDate=@ProbabtionDate,
    EndDate=@EndDate, RetirementDate=@RetirementDate,
    FundingBody=@FundingBody,
    ResearchGroup=@ResearchGroup, LineManager=@LineManager,
    PayCategory=@PayCategory, Notes=@Notes WHERE ID=@ID"
    >
     
    DC, Sep 12, 2007
    #3
  4. DC

    DC Guest

    Tried it and it gives an error like I expecetd

    Exception Details: System.Data.OleDb.OleDbException: Invalid SQL
    statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.

    Where can I actually put the Try code? the DetailsView calls
    "Validate_Insert_Data" OnItemInserting, and "Display_Insert_Msg"
    OnItemInserted.

    Im guessing I need to put the try code into Validate_Insert_Data yes?

    <asp:DetailsView id="DetailsView" DataSourceID="DetailsSource"
    Runat="Server"
    AutoGenerateRows="False"
    DataKeyNames="ID"
    OnItemInserting="Validate_Insert_Data"
    OnItemInserted="Display_Insert_Msg"
    OnItemUpdating="Validate_Update_Data"
    OnItemUpdated="Display_Update_Msg"
    OnItemDeleting="Confirm_Delete"
    OnItemCommand="Get_Command"
    BorderStyle="Outset"
    BorderWidth="1"
    CellPadding="3"
    GridLines="None">
     
    DC, Sep 12, 2007
    #4
  5. DC

    bruce barker Guest

    currently this feature does not exist (does in the linq library in the
    next release). your best bet is to use sqlprofile a utility that comes
    with sqlserver.

    -- bruce (sqlwork.com)

    DC wrote:
    > Ok so Im getting an
    >
    > " 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."
    >
    > Question is how do I get the detailsview to output the actual SQL
    > staemnet Im trying to execute to screen so I can debug my INSERT and
    > UPDATE statements?
    >
    > Thanks in advance,
     
    bruce barker, Sep 12, 2007
    #5
  6. DC

    DC Guest

    bruce barker wrote:
    > currently this feature does not exist (does in the linq library in the
    > next release). your best bet is to use sqlprofile a utility that comes
    > with sqlserver.


    Im not using SQL Server, Im using an <asp:AccessDataSource to use an
    Access database.
     
    DC, Sep 12, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cannontrodder
    Replies:
    1
    Views:
    733
    cannontrodder
    Jul 25, 2006
  2. news.sbcglobal.net

    Newbie: Help with DetailsView insert

    news.sbcglobal.net, Oct 2, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    403
    news.sbcglobal.net
    Oct 2, 2006
  3. eagle

    Insert & Insert/Repeat buttons in a detailsview

    eagle, Jul 12, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    1,060
    eagle
    Jul 12, 2007
  4. Feege
    Replies:
    0
    Views:
    463
    Feege
    Dec 20, 2005
  5. Mav
    Replies:
    22
    Views:
    366
Loading...

Share This Page