Page 1 of 1
How can I execute sql commands in IX?
Posted: Thu Jun 07, 2012 3:42 am
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.
Re: How can I execute sql commands in IX?
Posted: Thu Jun 07, 2012 6:39 am
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
Re: How can I execute sql commands in IX?
Posted: Thu Jun 07, 2012 7:01 am
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
Re: How can I execute sql commands in IX?
Posted: Thu Jun 07, 2012 8:04 am
by mark.monroe
Hi memethemyn,
Have you tried using the following function?
You need the path to the database. On a T7A that path is, "\FlashDrive\Project\Database.sdf"
Re: How can I execute sql commands in IX?
Posted: Fri Jun 08, 2012 4:09 am
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
Re: How can I execute sql commands in IX?
Posted: Fri Jun 08, 2012 7:03 am
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
Re: How can I execute sql commands in IX?
Posted: Tue Jun 12, 2012 8:31 am
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.