I am new to SQLITE and in my project, i need to select the data from the .db file but unfortunately, the data which I am selecting is too big. The query is
SELECT distinct * FROM RunTime WHERE Local_Machine = 'GTS-VINAY' and ((Variable like '[MCUL_ErrorMessage#2]%') or (Variable like '[MCUL_UniqueID#1]%')[....])
Here an exception was thrown Expression tree is too large (Maximum depth 1000) I googled a lot and found that people are saying to set limit of SQLITE_LIMIT_EXPR_DEPTH with reference to link http://forums.devart.com/viewtopic.php?f=48&t=31731#p109439
But here the question is how can I implement the same in C# WinForms.
Note: I am trying to add reference of sqlite3 in by project but vs 2013 is not allowing to add the same.
Put all the patterns into a temporary table, and let the database iterate over it:
SELECT RunTime.*
FROM RunTime
JOIN TempTable ON RunTime.Variable LIKE TempTable.Variable
WHERE Local_Machine = 'GTS-VINAY';
Related
Going a bit old school today trying to fix a bit of software that is running in a manufacturing plant importing data from a CSV file into an access database which is used to generate Crystal reports!
The original CSV file is in RANK (1,2,3, etc) order but when its imported using the following code it often arrives in the Access database out of order.
using (OleDbCommand accComm2 = new OleDbCommand(String.Format("SELECT TOP 100 PERCENT vCSV.* INTO {0} FROM [Text;FMT=Delimited;HDR=YES;IMEX=1;DATABASE={1}].[{2}] as vCSV ORDER BY vCSV.RANK", dbtable, Path.GetDirectoryName(fname), Path.GetFileName(fname)), accConn, accTran))
{
accComm2.ExecuteNonQuery();
}
This causes issues further down the line as the quirky crystal report manufacturing summarys that are created require the data to be in rank order.
Because the Crystal report is grouped into batches, you cant do the sorting on the crystal report end.
Does anyone have any ideas why the above wouldnt be working? Weve even tried importing it to a temporary table and then to the live table, effectively doing the sort command twice but it still sometimes fails!
You should sort in a subquery before inserting. Sorting while inserting has no effect in Access, besides the preview you can get while inserting.
SELECT * INTO {0} FROM (SELECT TOP 100 * [Text;FMT=Delimited;HDR=YES;IMEX=1;DATABASE={1}].[{2}] ORDER BY RANK) as vCSV
Note that, strictly speaking, the resulting table has no index thus is a heap and has no defined sort order (there is no first/second/nth record, any ordering is equally valid). Practically, this will likely work, though.
I've an old system where I have to read data from. It's stores the data an old Visual FoxPro DBF Table.
In C# I'm using adodb.dll with Provider=VFPOLEDB.1 to get the data and it works well so far.
When I select following (its an index):
select * from tableXYZ where tab_f1+STR(tab_f2,10)+STR(tab_f3,3)+STR(tab_f4,3)+STR(tab_f5,3) = "AR1234567890"
I get in Visual FoxPro a fast result (using the index), "AR" is the tab_f1, "1234567890" is the STR(tab_f2,10). The tab_f3, tab_f4 and tab_f5 seems to be "ignored", even filled in the table i get all the rows, regardless of the content of f3 to f5.
The same select in c# with the ADODB Connection returns no result set. Is there a way to let the VFPOLEDB ignore the three fields behind too or do i need an index only for tab_f1+tab_f2?
VFP will treat = as "starts with" based on the SET ANSI setting. If you want to use that same functionality in ADODB I would use LIKE instead:
select *
from tableXYZ
where tab_f1+STR(tab_f2,10)+STR(tab_f3,3)+STR(tab_f4,3)+STR(tab_f5,3) LIKE "AR1234567890%"
However note that ADODB will not use stand-alone ("IDX") index files. If your index in in a CDX associated with that table then it should be used.
i would like a clear answer of why can't i process a query like this one with OleDb
"select top 0 * FROM [APPELLATION$] WHERE (((([libel_app] LIKE '%g') OR ([region] LIKE '%g')) OR ([couleur] LIKE '%g')))"
I can with SQL but when i try to fetch some data from an Excel file it throws an error that tells me that i use some restricted word or i have some symbols that are restricted. I read the list of restricted words and symbols and did not find any of them in my query. My program is giving me SQL request, i would not like to end up looking if the TOP N number is whether or not is zero, but if i have no solution...
Thanks in advance.
Your collegues should remove hard-coded flavor-specific SQL from their code in the first place especially if it is to be used on different types of connections.
See the accepted answer on Is there an ANSI SQL alternative to the MYSQL LIMIT keyword? for some of the flavors. Excel is not listed there, I bet it uses the same syntax as MsAccess but I'm not suprised it acts completely different upon such a weird query. As Paddy already mentioned that query does not make any sense, and should be avoided.
Fixing this by matching "SELECT TOP 0" is ugly and will make maintaining software pure hell (been there :( )
The N in TOP N must be a numeric value of 1 (Banker's rounded) or greater.
e.g.
SELECT TOP 0.5 * FROM MyTable; -- rounds to zero = error
SELECT TOP 0.6 * FROM MyTable; -- rounds to 1 = no problem
I'm using SQLite to compare some ids (varchar 50) so I get a numeric database id.
I'm using C# and visual studio 2003. Pretty new in C# so maybe I'm doing a newbie mistake.
When doing some comparison like the following
SELECT * FROM tblUSer WHERE Use_id like '%Ñ120%'
I don't get anything even if this exist... I suppose is an encoding problem, but I don't know how to solve it.
I can't change the database schema since is not my database (need to modify select some data and update a field).
I can't change the data per se since it is a data that already exist and the user codes are the same as some reference like a club id or something...
Changing the data to UTF-8 worked to make it do the query (without it it would give an error) but still I don't get the desired data. Maybe is also how the data is saved by the original program.
What do I do so my query works with the Ñ?
What if your remove the N from your query and just check
Use_id LIKE '%120%'
and then select the appropriate ones in C#?
try this:
SELECT * FROM tblUSer WHERE Use_id like N'%Ñ120%'
Notice the N letter.
You should write in this way:
SELECT * FROM tblUSer WHERE Use_id like N'%Ñ120%'
Working on a pet project concerning efficiency and data and this is the mission statement:
I have an Access DB with x amount of tables , each containing upwards of 2000 to a max of around 15000 entries in the format of [shipment][box][serial][name][region].
Now, I have another table(called Bluuur) with n amount of entries and I'd like to compare this table (contains serials) to all the tables in the Access DB and return the serial matches along with the name of the record which matched.
So the output should be something like :
Timmy 360 (for a compare in which Timmy had 360 matches to Bluuur)
note: I'm developing an application to do this
I would use the OleDbConnection with connection string like:
OleDbConnection connToFile = new OleDbConnection(String.Format(#"Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}; Extended Properties=""Excel 8.0;HDR=Yes"";", fileName));
Similar for MS Access. Then load both tables to the memory and compare.
Update
Ok, sorry that I didn't got your question initially.
The answer would more depend from requirements:
Is the table in XLS static or dynamic? If it is static then import the XLS into MS Access and, if you just need to get values for yourself use, use Query Editor to select and join tables like: select a.Name, count(b.ID) from tableA a inner join tableB b on a.Name = b.Name group by a.Name
If the table in XLS is dynamic, but once again you need to work with it for your own purposes, create the linked data source in MS Access to that XLS file and once again use query editor to perform the selection.
If the purpose of all this is to have the web page/application, which will connect to both the Microsoft Access and XLS and will join data, and will do that regularly you have 2 potential solutions: do it in memory, or do it using saved query and then use OleDbConnection/OleDbDataAdapter to load data into the application and display them to user. The memory approach may not be the best by performance so write the MS Access query, which will join and group data as you need and use OleDbConnection to connect MS Access MDB file and execute the query. OR, if you need to do this for multiple tables in MS Access, write the query text yourself directly in the code, execute for each join and then summ results.
If I underastand correctly then one table (to which you need to compare) is not in MS Access DB. Quick solution seems as follows: import "Bluur" table to Access database (most probable it's possible with Access import data wizard). Now you can use simple JOIN queries to test agains all other table in DB.