user1029651
user1029651

Reputation: 33

Regex for SQL(sql); C#

I am having some trouble with a regular expression (don't know if what I want to do is possible.)

Scenario:

I have an input area where users can write some text. They would like to be able to also execute some SQL query where the result is then going to be displayed in the text, when the text is sent to a customer in an email.

Rough example:

#

Hi

I have attached the invoice SQL(SELECT DocNumber FROM X WHERE DocEntry IN (SELECT DocEntry FROM X););

Please provide payment for the invoice.

Regards

#

I am having some difficulties handling that the users can write () and ; in SQL.

Have anyone done something like this before with regex or am I going to do have to do some ugly split, substring and last index of in C#?

Any comments/suggestions would be much appreciated.

Upvotes: 1

Views: 136

Answers (1)

CodeCaster
CodeCaster

Reputation: 151588

You really don't want to do this. Why not just use templating, so your user can type %%invoiceNo%% and your code looks up the invoice number using the appropriate query?

Upvotes: 3

Related Questions