Re: My queries don't work after I upgraded to SQL Server Compact 3.5

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks Ginny.

Yes, I got it to work using the @[parameter_name] instead of using just a ?
It's strange. It works ok with CF2.0 but it doesn't with CF3.5

Thanks for your help.

Ginny Caughey [MVP] wrote:
Star,

I was able to reproduce the error you saw even on the desktop. I was also able to work around it (on desktop and CF) using this type of coding:

string cSQL = "Insert into Positions (Latitude,Longitude,Speed,Altitude,DateAdded,DateOccurred) ";
cSQL += "Values (@Latitude, @Longitude, @Speed, @Altitude, @DateAdded, @DateOccurred) ";
SqlCeCommand sqlCommand = conn.CreateCommand();
sqlCommand.CommandText = cSQL;
sqlCommand.Parameters.AddWithValue("@Latitude", 3.2133);
sqlCommand.Parameters.AddWithValue("@Longitude", 5.2133);
sqlCommand.Parameters.AddWithValue("@Speed", 3.1);
sqlCommand.Parameters.AddWithValue("@Altitude", 1.2);
sqlCommand.Parameters.AddWithValue("@DateAdded", DateTime.Now);
sqlCommand.Parameters.AddWithValue("@DateOccurred", DateTime.Now);
sqlCommand.ExecuteNonQuery();

I have seen something similar with SQL Server so I don't believe it's specific to SQL Compact 3.5 or Compact Framework. In general I have fewer problems using Parameters.AddWithValue, and it's a little less code.

HTH,

.



Relevant Pages

  • Re: SQLServer2005/SQLC 3.5 Merge Replication
    ... Check out my SQL Compact blog at ... Create a SQL Server Compact Subscription (SQL Server Management ...
    (microsoft.public.sqlserver.ce)
  • Re: SQLServer2005/SQLC 3.5 Merge Replication
    ... Paul T. ... How to: Create a Subscription (Programmatically) ... Create a SQL Server Compact Subscription (SQL Server Management ... would work with SQL Server 2005 and SQL Compact 3.5? ...
    (microsoft.public.sqlserver.ce)
  • Re: Database for a Pocket PC - Desktop syncing application
    ... New data type - rowversion ... Device Application Development MVP ... I cannot use SQL Compact 3.5 as all my development systems are still using VS 2005. ... I can use SQL Server mobile on PDA but the SQL Server on the desktop will be overkill for my targer audience. ...
    (microsoft.public.pocketpc.developer)
  • SQLServer2005/SQLC 3.5 Merge Replication
    ... Can anyone point me to a smart device sample for merge replication that ... would work with SQL Server 2005 and SQL Compact 3.5? ... a suitably-prepared server database, publication, etc., but don't see how to ...
    (microsoft.public.sqlserver.ce)