A Sql query problem :(

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
memethemyn
Posts: 51
Joined: Fri Apr 27, 2012 12:33 pm

A Sql query problem :(

Post by memethemyn »

Hi..

In my project I have given uniqe test reference numbers to my pump tests.
The reference numbers are like 040912-1345 as string.. so I want to pull data from database using this code

Code: Select all

DatabaseViewer2.SendSelectQuery(@"Select * from Test6 where TestRefNum="+Globals.Tags.Test_Referans_No.Value+"", @"C:\Users\Public\Documents\Beijer Electronics AB\iX Developer Runtime 2\Project\database.sdf");
 
but it wasn't worked :(

In database viewer I used

Code: Select all

Select * from Test6 where TestRefNum='040912-1345'
this query returns me value but the query upside didn't work..

I tried to use Convert.ToInt16 but didn't worked again..

Please help..

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: A Sql query problem :(

Post by mark.monroe »

I think you need to use an escape sequence. I would try,

Code: Select all


string query = "Select * from Test6 where TestRefNum=\'" + Globals.Tags.Test_Referans_No.Value + "\'";

DatabaseViewer2.SendSelectQuery(query, @"C:\Users\Public\Documents\Beijer Electronics AB\iX Developer Runtime 2\Project\database.sdf");
Make sure that your "Test_Referans_No" tag is set to a string.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

Post Reply