I am pulling the hair out of my head trying to figure this one out.
I can\'t make Parameterized queries to work in VB.Net, when I am using parameters.
From w
Finally, I have found the solution for this problem.
Using a parameter in a function crashes if the DBType property of the parameter is not set:
This will crash:
Dim cmd As SqlCeCommand = db.CreateCommand()
cmd.CommandText = "SELECT COALESCE(@param1, @param2);"
cmd.Parameters.Add("@param1", 1)
cmd.Parameters.Add("@param2", "test")
cmd.ExecuteScalar()
Using a parameter in a function will work if the DBType property of the parameter is set
This will work:
Dim cmd As SqlCeCommand = db.CreateCommand()
cmd.CommandText = "SELECT COALESCE(@param1, @param2);"
cmd.Parameters.Add("@param1", 1).DbType = DbType.Int32
cmd.Parameters.Add("@param2", "test").DbType = DbType.String
cmd.ExecuteScalar()