Print Page | Close Window

Add Command To Report

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3197
Printed Date: 02 May 2024 at 10:33pm


Topic: Add Command To Report
Posted By: solent
Subject: Add Command To Report
Date Posted: 16 May 2008 at 4:34am
I have created the following Command  in the Database Expert for test.
 
INSERT INTO tblUsers
(UserName)
VALUES
({?Draft})
 
SELECT UserName FROM tblUsers
 
{?Draft} is a string parameter and prompts ok
 
However entering TestName in the parameter field and clicking OK results in the following error:
 
"Failed to retrieve data from the Database"
"The name TestName is not permitted in this context"
"Valid expresssion are constants........"
 
Any help would be appreciated



Replies:
Posted By: Lugh
Date Posted: 16 May 2008 at 4:44am
You can only use SELECT statements in the Command text.  You can't update the database from Crystal in that way.

Though, as a note, if you put a stored procedure in your database, that stored procedure can do anything any other stored procedure can do.  And, you can make any stored procedure the data source of the report, even if it doesn't return any records.  So, you could create a stored proc that does this.  (I'm guessing, though, that you are attempting to do it this way because creating a new stored proc is not a possibility for you.)




Posted By: solent
Date Posted: 19 May 2008 at 1:53am

Lugh,

Thanks for the reply.  You will find that you can use Update and Insert statements within a Command , not just select statements.  However the Command must return a record so you must include a select as in the above case.

Thanks

 

 

 




Print Page | Close Window