Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7595011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:33:52+00:00 2026-05-30T21:33:52+00:00

During the development of an windows mobile application we used the following code: const

  • 0

During the development of an windows mobile application we used the following code:

const string sqlString2 = 
   @"INSERT INTO WorkOrderComment
   (WOInstructionID,WorkOrderCommentID,ClientChange,Void,UserID,VoidTimestamp) 
   (SELECT WOInstructionID, WOInstructionID, 1, @VoidBit,@VoidUser ,@VoidTimeStamp 
    FROM WorkOrderInstruction 
    WHERE InstructionGroupQuestion = 0 AND InstructionGroupNumber = @insGroupNo AND WorkOrderID=@WoID)";
var sqlcom2 = new SqlCeCommand();
sqlcom2.CommandType = CommandType.Text;
sqlcom2.CommandText = sqlString2;
sqlcom2.Parameters.Add("@VoidBit", action);

sqlcom2.Parameters.Add("@VoidUser", DBNull.Value);
sqlcom2.Parameters.Add("@VoidTimeStamp", DBNull.Value);

sqlcom2.Parameters.Add("@WoID", workOrderID);
sqlcom2.Parameters.Add("@insGroupNo", instructionGroupNumber);
sqlcom2.ExecuteNonQuery();

When running this with I receive the following error on ExecuteNonQuery:
The conversion is not supported. [ Type to convert from (if known) = int, Type to convert to (if known) = uniqueidentifier ]

Even if I add sqlcom2.Parameters["@VoidUser"].DbType = DbType.Guid; I got the same error. After a while I found that this could be helped with using CONVERT.
I changed @VoidUser to CONVERT(uniqueidentifier,@VoidUser).

This resulted in the following error: A parameter is not allowed in this location. Ensure that the '@' sign is in a valid location or that parameters are valid at all in this SQL statement.

After a couple of hours of reading documentation and other posts on why I could not use variables at these places I just tried to put in CONVERT everywhere; changing @VoidBit to CONVERT(bit,@VoidBit) and @VoidTimeStamp to CONVERT(datetime,@VoidTimeStamp).

And for some reason it works.

The table is created with this command:

CREATE TABLE WorkOrderComment (  WorkOrderCommentID uniqueidentifier NOT NULL CONSTRAINT WorkOrderCommentPK Primary Key,
WOInstructionID uniqueidentifier NOT NULL,
WorkOrderID_Update uniqueidentifier NULL,
TextData NTEXT NULL,
Value float NULL,
Category nvarchar(50) NULL,
BarcodeScanned bit NULL,
Timestamp DateTime NULL,
Time float NULL,
UserID uniqueidentifier NULL,
Void bit NULL,
VoidTimeStamp DateTime NULL,
FaultComplaintID uniqueidentifier NULL,
ClientChange bit NOT NULL)

Why am I not allowed to use “naked” parameters?

Why did it throw an error on the conversion in the first place, and not the usage of a parameter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:33:53+00:00Added an answer on May 30, 2026 at 9:33 pm

    The Parameters.Add() method takes 2 parameters: Parameter name and data type. It seems you are confusing with Parameters.AddWithValue()

    Also SQLCE seems to be more difficult with type conversion than SQL Server. So the best is you specifically mention the type of the parameters. (it only really matters for uniqueidentifier though)

    I would slightly rewrite the code like this as well:

            using (var sqlConn = new SqlCeConnection(connStr))
            using (var sqlCmd = new SqlCeCommand(sqlString2, sqlConn))
            {
                sqlConn.Open();
    
                sqlCmd.Parameters.Add("@VoidBit", SqlDbType.Bit).Value = action;
                sqlCmd.Parameters.Add("@VoidUser", SqlDbType.UniqueIdentifier).Value = DBNull.Value;
                sqlCmd.Parameters.Add("@VoidTimeStamp", SqlDbType.DateTime).Value = DBNull.Value;
                sqlCmd.Parameters.Add("@WoID", SqlDbType.UniqueIdentifier).Value = workOrderID;
                sqlCmd.Parameters.Add("@insGroupNo", SqlDbType.Int).Value = instructionGroupNumber;
    
                sqlCmd.ExecuteNonQuery();
            }
    

    See https://gist.github.com/1932722 for full repro script

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far during my experience in Windows Phone 7 application development I notices there
I am working on a large (100s of assemblies) asp.net application and during development
During my days doing Winforms development, I constantly found myself struggling against System.Windows.Forms controls.
During development i have observed that certain PDAs with Windows CE and possibly Windows
I've been using Git on both Windows and Ubuntu during the development of a
At work we use a mixture of Windows and Linux workstations during development. For
Greetings to this great community. Here is my question. During development of .NET Windows
During development I have to clear cache in Firefox all the time in order
During development (and for debugging) it is very useful to run a Java class'
During development, I use this to load the latest jQuery: <script src=http://www.google.com/jsapi></script> <script type=text/javascript>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.