logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Aruna  
#1 Posted : Friday, November 20, 2015 9:27:45 AM(UTC)
Aruna

Rank: Member

Groups: Registered
Joined: 11/4/2015(UTC)
Posts: 17
India

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
I need to pass parameters to my SQL query to create a Table in SR. However I am getting following error "Command text was not set for the command object." Could anybody help me resolve this issue.

SQL query : select * from table1 where columns_name = @PL

Pre SQL statement :
Quote:
@using Seal.Model
@{
var PL = "3000";
}


Sorry for the very simple thing, I am new to Razor scripting.

Edited by user Friday, November 20, 2015 9:30:58 AM(UTC)  | Reason: Not specified

epf  
#2 Posted : Friday, November 20, 2015 10:49:35 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
razor script are just c#
in which property do you want to use it ?
Aruna  
#3 Posted : Friday, November 20, 2015 10:59:12 AM(UTC)
Aruna

Rank: Member

Groups: Registered
Joined: 11/4/2015(UTC)
Posts: 17
India

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
I need this in table's SQL statement.

I have case statements in my SQL query, and i need to pass restriction values over to case statement conditions.
epf  
#4 Posted : Friday, November 20, 2015 11:17:29 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
you can use razor script only in the following table properties:
Pre SQL Statement
Post SQL Statement
Additional WHERE Clause: this one can add dynamically restrictions to your table, check the sample provided.
Aruna  
#5 Posted : Friday, November 20, 2015 11:35:30 AM(UTC)
Aruna

Rank: Member

Groups: Registered
Joined: 11/4/2015(UTC)
Posts: 17
India

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
I am using razor script in Pre SQL statement.In there i am creating a variable called 'PL' and using that in my table's SQL query. But its giving "Command text was not set for the command object." error for me.

Quote:

@using Seal.Model
@using Seal.Helpers
@{

string PL = string.Format("", Helper.QuoteSingle("3000"));

}
@Raw(PL)


Please see the code snippet above

Edited by user Friday, November 20, 2015 11:37:46 AM(UTC)  | Reason: Not specified

epf  
#6 Posted : Friday, November 20, 2015 3:08:03 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
Yes, the pre-SQL (or post-SQL) is done to send an SQL command to the database (e.g. creating a table or a view)
So it must be a SQL statement it has no link with the SQL generated.

I think you should not use this for your purpose.

Users browsing this topic
Guest (3)
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.