Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Add Command To Report Post Reply Post New Topic
Author Message
solent
Newbie
Newbie


Joined: 07 Apr 2008
Location: United Kingdom
Online Status: Offline
Posts: 22
Quote solent Replybullet Topic: Add Command To Report
    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
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet 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.)


IP IP Logged
solent
Newbie
Newbie


Joined: 07 Apr 2008
Location: United Kingdom
Online Status: Offline
Posts: 22
Quote solent Replybullet 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

 

 

 

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.032 seconds.