I've run into an issue installing a product that has worked at several customer sites just fine, I believe the issue has to do with the Collation setting on their database server. I have code that looks like this (I changed table and variables names around since the code is proprietary):
using (SqlCommand insertCommand = dbConnection.CreateCommand())
{
insertCommand.CommandText = "INSERT INTO [myTable] ([valueOne] ,[valueTwo] ,[CreationDate]) VALUES (@valueTwo ,@valueTwo ,@creationDate);select IDENT_CURRENT('myTable');";
insertCommand.Parameters.AddWithValue("@valueOne", "Value One");
insertCommand.Parameters.AddWithValue("@valueTwo", "Value Two");
insertCommand.Parameters.AddWithValue("@CreationDate", CreationDate);
dbConnection.Open();
object result = insertCommand.ExecuteScalar();
dbConnection.Close();
}
This works at most sites and on our development and QA machines, but at this one site we receive an error that says "Must declare scalar variable "@creationDate". The main discrepancy I see is that the site has the collation value set to SQL_Latin1_General_CP1_CS_AS and our settings are all SQL_Latin1_General_CP1_CI_AS. I changed this for our database but the server is still set to the Case Sensitive variation. This did resolve another issue we were having with a different table (that one was the table name, not a parameter name), but for some reason it's still a problem for this. Does anyone have any ideas on how I can resolve this a little more quickly than going through and fixing all of the case differences in our code base?
The site is using SQL Server 2005, and our code is written in C# and .NET 3.5.
Thanks -Hollis