0
Sqlcommand cmd=new Sqlcommand();
cmd.commandtext="select username, password from \"user\" where username = 'admin' 
 and password = 'password123' ";
adp.fill(ds);

Now above query is getting succesffuly executed in mysql and mssql,but my C# code is giving error incorrect sytax "user" Where I am wrong? NOTE:-I want above query to run in mysql and mssql both,and also note that user is reserved keyword in sql

1 Answer 1

2

For MySQL use

from `user`

For SQL Server use

from [user]

For Oracle use

from "user"
Sign up to request clarification or add additional context in comments.

4 Comments

But I dont want to write 3 statements I want common C# code to run this query
I don't think this is going to happen.
If you want to keep it generic why not just remove the quotes: FROM user
@DaveSexton: That does not work for SQL Server. Only for MySQL as far as I know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.