Reputation: 6070
I have used the migration feature in WebMatrix to migrate my .sdf database to SQL Server. I am now getting the error below:
var usernameExists = db.Query("SELECT Username FROM Users WHERE Username = ?", username);
[SqlException (0x80131904): Incorrect syntax near '?'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2073502
Do I need to add code to indicate which Database to open? Will I now need to change the syntax for all my database queries? Sorry, I am new to SQL Server and am finding it very difficult to find any resources for migrating using WebMatrix and what I need to do to get my application fixed and working fully.
Upvotes: 1
Views: 104
Reputation: 10219
Try changing your ?
to @0
. Different database providers use different placeholders for parameters. The SqlClient one uses @parametername syntax.
Upvotes: 2