473,411 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Problem using command.parameters

I need to get data from a sql server database and insert records into a sqlce
database if they do not already exist in the sqlce database. I have written
the code below but I'm getting an error message when the cmd.Prepare() line
is executed. The error message is - "The conversion is not supported. [ Type
to convert from (if known) = int, Type to convert to (if known) =
uniqueidentifier ]"}

I have compared the ordinal position of each parameter to the SqlDbType and
they all match. I don't have any idea why I'm getting the error message or
how to debug it at this point. Any help would be much appreciated.
cmd.CommandText =
"Insert VMI_CUST (CUST_ID, SHIP2_ID, CUST_NO,
QUICK_SCAN, ALLOW_DUPLICATE_SCANS, SIGNATURE_REQUIRED, " +
"VALIDATE_MANDATORY_ITEMS, PO_TYPE, CUST_PO,
LAST_CHANGE_DATE, RELEASE_NO, LAST_SYNC_DATE, COMPANY_ID) " +
"Select " +
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " +
"'" + Global.CompanyID + "' " +
"FROM vmi_controls " +
"WHERE vmi_controls.company_id = '" +
Global.CompanyID + "'"; //+
" AND NOT EXISTS " +
"(SELECT cust_id FROM vmi_cust WHERE
cust_id = '" + drCustomers[x]["CUST_ID"] + "'" +
" and ship2_id =
'" + drCustomers[x]["SHIP2_ID"] + "'" +
" and company_id =
'" + Global.CompanyID + "')";

cmd.Parameters.Clear();

cmd.Parameters.Add(new SqlCeParameter("CUST_ID",
SqlDbType.UniqueIdentifier));
cmd.Parameters.Add(new SqlCeParameter("SHIP2_ID",
SqlDbType.UniqueIdentifier));
cmd.Parameters.Add(new SqlCeParameter("CUST_NO",
SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("QUICK_SCAN",
SqlDbType.NVarChar));
cmd.Parameters.Add(new
SqlCeParameter("ALLOW_DUPLICATE_SCANS", SqlDbType.NVarChar));
cmd.Parameters.Add(new
SqlCeParameter("SIGNATURE_REQUIRED", SqlDbType.NVarChar));
cmd.Parameters.Add(new
SqlCeParameter("VALIDATE_MANDATORY_ITEMS", SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("PO_TYPE",
SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlCeParameter("CUST_PO",
SqlDbType.NVarChar));
cmd.Parameters.Add(new
SqlCeParameter("LAST_CHANGE_DATE", SqlDbType.DateTime));
cmd.Parameters.Add(new SqlCeParameter("RELEASE_NO",
SqlDbType.NVarChar));
cmd.Parameters.Add(new
SqlCeParameter("LAST_SYNC_DATE", SqlDbType.DateTime));

cmd.Prepare();
Jul 23 '07 #1
0 1261

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sandie Towers | last post by:
We use a number of similar databases and frequently create a new database using a backup restore of another similar database. We try to keep changes between databases in _Additional tables - like...
0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
4
by: NS | last post by:
Hi, I am trying to execute a prepare statement using oledb provider for DB2. The command.Prepare() statement is giving me an exception " No error information available:...
3
by: alexmaster_2004 | last post by:
hi i have made an application using C# that access sql2000. this application is just used to insert data to the database. i use something like this in my code: // string colmnA = TextBox1.Text;...
5
by: Jason Huang | last post by:
Hi, The SqlParameter myPM =new SqlParameter("@Address", txtAddress.Text) is working for update, but SqlParameter myPM =new SqlParameter ("@Address",SqlDbType.NVarChar,90,txtAddress.Text) is...
1
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say...
1
by: Eustice Scrubb | last post by:
I'm trying to use the Insert.aspx Quickstart and I'm getting a NULL pointer exception. Any help? <code> <script language="VB" runat="server"> Dim myConnection As SqlConnection Sub...
0
by: Evandro Klen S. Azeredo | last post by:
Hi, I'm with the folowing problem: I have two tables: header(id_header) and Itens(id_header, id_item). When I insert data in Itens table, this error is returned: "You cannot add or change a...
8
by: Martin Z | last post by:
INSERT INTO dbo.Transmission (TransmissionDate, TransmissionDirection, Filename, TransmittedData) VALUES (@TransmissionDate,@TransmissionDirection,@Filename,@TransmittedData); SELECT @retVal =...
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.