Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite in C# with REGEXP

Tags:

c#

regex

sqlite

I'm trying to build a search query to match whole words in SQLite and C# on Windows. When I run a query like this:

SELECT a, b FROM Events WHERE c REGEXP @SearchString;

Then:

cmd.Parameters.Add(new SQLiteParameter("@SearchString", 
"%[^a-zA-Z0-9]" + searchdata.SearchText + "[^a-zA-Z0-9]%"));

And when I call:

var r = cmd.ExecuteReader();

I get REGEXP no such function. I wonder how to activate REGEXP support and CASE SENSITIVE search.

like image 797
Pablo Yabo Avatar asked Dec 16 '13 22:12

Pablo Yabo


People also ask

Is SQLite written in C?

SQLite is written in ANSI-C. The C programming language is used because it is the universal assembly language - it can run on just about any hardware and on just about any operating system. No matter what programming language is used for the application code, it can usually interface easily with a library written in C.

What SQLite is used for?

SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation.

Is SQLite a SQL?

What Is SQLite? SQLite is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine. SQLite is the most used database engine in the world.

Is SQLite better than SQL?

SQLite is generally a lot faster than MS SQL Server if dealing with small-size databases. SQLite can be integrated with different programming languages and environments including . NET.


1 Answers

I've got it! The problem was that I didn't define the REGEXP function. I've got from here: here a definition for C#.

like image 102
Pablo Yabo Avatar answered Sep 28 '22 22:09

Pablo Yabo