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

D

DC

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,
 
N

New Bee

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
 
D

DC

New said:
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"
 
D

DC

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

bruce barker

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)
 
D

DC

bruce said:
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.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top