Simon Kiely
Simon Kiely

Reputation: 6070

Error after migrating database from SQL Server CE to SQL Server

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

Answers (1)

patmortech
patmortech

Reputation: 10219

Try changing your ? to @0. Different database providers use different placeholders for parameters. The SqlClient one uses @parametername syntax.

Upvotes: 2

Related Questions