Re: My queries don't work after I upgraded to SQL Server Compact 3.5
- From: Star <star@xxxxxxxxxx>
- Date: Sun, 06 Jan 2008 11:42:45 +0100
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,
- References:
- My queries don't work after I upgraded to SQL Server Compact 3.5
- From: Star
- Re: My queries don't work after I upgraded to SQL Server Compact 3.5
- From: Ginny Caughey [MVP]
- My queries don't work after I upgraded to SQL Server Compact 3.5
- Prev by Date: Re: how safe is it using private member as encryption key
- Next by Date: How can i get the owner's name of the device
- Previous by thread: Re: My queries don't work after I upgraded to SQL Server Compact 3.5
- Next by thread: RE: ObjectDisposedException
- Index(es):
Relevant Pages
|