i am currently writting a method that reads date from a firebird database.
Here is the Header :
public static void ReadInfo(int first, int skip,string orderBy)
That is my SQL Query :
const string SQL = "SELECT FIRST @first SKIP @skip A.ID,B.SHORTNAME, A.DATETIME, A.COMPUTERNAME,A.OSLOGIN, A.DBLOGIN, A.INFOTYPE, A.INFO FROM EVENTSGENERAL A JOIN EVENTSGENERATORS B ON B.GENERATOR_ = A.GENERATOR_ ORDER BY @orderBy";
And here is where i prepare the parameters for the query:
cmd.Parameters.Add("@first", FbDbType.Integer).Value = first;
cmd.Parameters.Add("@skip", FbDbType.Integer).Value = skip;
cmd.Parameters.Add ("@orderBy", FbDbType.VarChar, 50).Value = orderBy;
The problem is: The first two parameters work (first and skip are prepared correctly),i´ve tested it. But,the orderBy parameter raises an exeption once i try to run it :
{"Dynamic SQL Error\r\nSQL error code = -804\r\nData type unknown"}
I´ve tried to change toe FbDbType to “Text”,but still not working.
Sorry about any bad english.
Thanks in advance for any help given.
For
order byclause needs field specified you cant pass field name. What may work is if you make@orderByparameter datatype integer and pass index of field. for exampleor if you programmatically edit sql statement like this: