How can I execute sql commands in IX?

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
memethemyn
Posts: 51
Joined: Fri Apr 27, 2012 12:33 pm

How can I execute sql commands in IX?

Post by memethemyn »

Hi..

For my project i must run sql commands in IX.

For example 'select * from test6 order by id desc'. I want to ask this command and show the results on databaseviewer.

Thanks already.

bjornidar
Posts: 49
Joined: Thu Nov 17, 2011 2:10 am
Location: Norway
Contact:

Re: How can I execute sql commands in IX?

Post by bjornidar »

Well, the DatabaswViewer runs the SQL-queries for you, you just have to select the Database.sdf-file you wan't to fetch data from..

But if you are scripting something in iX Developer you can use ordinary connection-strings against a SQL Compact edition

http://www.connectionstrings.com/sql-server-2005-ce

memethemyn
Posts: 51
Joined: Fri Apr 27, 2012 12:33 pm

Re: How can I execute sql commands in IX?

Post by memethemyn »

Dear bjornidar,

I already use to test my sql commands in Databaseviewer but in I wanted to say the databaseviewer object in developer program.

For example think that a button in the project and i write script into it as:

databaseviewer1.showdata();

When I lick the button the database viewer shows me the every data in the datababse ( eg. test 6 ) This is the reason I want to filter my datas :(

I hope I can tell myself :(

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

Re: How can I execute sql commands in IX?

Post by mark.monroe »

Hi memethemyn,

Have you tried using the following function?

Code: Select all

DatabaseViewer1.SendSelectQuery
You need the path to the database. On a T7A that path is, "\FlashDrive\Project\Database.sdf"
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

memethemyn
Posts: 51
Joined: Fri Apr 27, 2012 12:33 pm

Re: How can I execute sql commands in IX?

Post by memethemyn »

Dear Mark..

I tried to use this code but the compiler occured error:(

Code: Select all

DatabaseViewer1.SendSelectQuery("select * from tes6","C:\Users\MEHMET\Desktop\Test Sistemi Yeni Tasarım\IX Tasarım\Project3\database.sdf");
The error is Unrecognized Escape sequence

thanks already..

PM: I'm new at scripting and C# so i ask forum many things. I hope this situation doesn't disturb you :(

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

Re: How can I execute sql commands in IX?

Post by mark.monroe »

I would suggest going through a few tutorials online, and reading up on C#. It is a very complex and powerful language.

Code: Select all

DatabaseViewer1.SendSelectQuery(@"select * from tes6",@"C:\Users\MEHMET\Desktop\Test Sistemi Yeni Tasarım\IX Tasarım\Project3\database.sdf");
Escape Sequences

String Literals
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

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

Re: How can I execute sql commands in IX?

Post by mark.monroe »

If you want to run a query on a database using the Database Viewer control on an iX panel that is running Windows CE, then you only need to use the name of the database. The application startup folder is automatically prefixed to the path when using the SendSelectQuery function.

Code: Select all

DatabaseViewer1.SendSelectQuery(@"select * from DataLogger1",@"Database.sdf");
That is not the case when running iX on a PC. Then you need to use the complete path to the database.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

Post Reply