.NET CF extremely buggy!

  • Thread starter Thread starter SSP
  • Start date Start date
S

SSP

cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))

cmd.Parameters["@cDateReg"].Value =
Convert.ToDateTime(cDateReg_tb.Text).ToShortDateString();
cmd.Parameters["@cDate"].Value =
Convert.ToDateTime(cDate_tb.Text).ToShortDateString();

Error Code: 80020005
Message: Data conversion failed. [OLE DB status value,,,,,,]

This is typical of the crap I am going through at the moment! If it works in
one instance why won't it work in another??

SSP
 
Do cDateReg_tb and cDate_tb hold the same value? What values doe they
contain?

-Chris
 
Why are you converting this to string before setting the param value?

What happens if you do this:

cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))

cmd.Parameters["@cDateReg"].Value = DateTime.Parse(cDateReg_tb.Text).Date;
cmd.Parameters["@cDate"].Value = DateTime.Parse(cDate_tb.Text).Date;

How is your table declared?
 
They both get passed the same test values ("1/1/2003").

Chris Tacke said:
Do cDateReg_tb and cDate_tb hold the same value? What values doe they
contain?

-Chris


SSP said:
cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))

cmd.Parameters["@cDateReg"].Value =
Convert.ToDateTime(cDateReg_tb.Text).ToShortDateString();
cmd.Parameters["@cDate"].Value =
Convert.ToDateTime(cDate_tb.Text).ToShortDateString();

Error Code: 80020005
Message: Data conversion failed. [OLE DB status value,,,,,,]

This is typical of the crap I am going through at the moment! If it
works
in
one instance why won't it work in another??

SSP
 
If I don't convert it then I get a "conversion failed" type of error.

Here's the interesting bit. This used to be the setup:
....
cmd.Parameters.Add(new SqlCeParameter("@cDOB", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cSPN", DbType.String));
cmd.Parameters.Add(new SqlCeParameter("@cSPS", DbType.String));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date));
....
cmd.Parameters["@cDOB"].Value =
Convert.ToDateTime(cDOB_tb.Text).ToShortDateString();
cmd.Parameters["@cSPN"].Value = cSPN_tb.Text;
cmd.Parameters["@cSPS"].Value = cSPS_tb.Text;
cmd.Parameters["@cDate"].Value =
Convert.ToDateTime(cDate_tb.Text).ToShortDateString();
....
I used to recieve the error:
Error Code: 80020005
Message: Data conversion failed. [OLE DB status value,,,,,,]

I moved the @cDate paramater right after the @cDOB and everything seemed to
sort itself.

I still have no idea?

SSP


Alex Feinman said:
Why are you converting this to string before setting the param value?

What happens if you do this:

cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))

cmd.Parameters["@cDateReg"].Value = DateTime.Parse(cDateReg_tb.Text).Date;
cmd.Parameters["@cDate"].Value = DateTime.Parse(cDate_tb.Text).Date;

How is your table declared?

SSP said:
cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))

cmd.Parameters["@cDateReg"].Value =
Convert.ToDateTime(cDateReg_tb.Text).ToShortDateString();
cmd.Parameters["@cDate"].Value =
Convert.ToDateTime(cDate_tb.Text).ToShortDateString();

Error Code: 80020005
Message: Data conversion failed. [OLE DB status value,,,,,,]

This is typical of the crap I am going through at the moment! If it
works
in
one instance why won't it work in another??

SSP
 
Could you post the structure of your data table?

SSP said:
If I don't convert it then I get a "conversion failed" type of error.

Here's the interesting bit. This used to be the setup:
...
cmd.Parameters.Add(new SqlCeParameter("@cDOB", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cSPN", DbType.String));
cmd.Parameters.Add(new SqlCeParameter("@cSPS", DbType.String));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date));
...
cmd.Parameters["@cDOB"].Value =
Convert.ToDateTime(cDOB_tb.Text).ToShortDateString();
cmd.Parameters["@cSPN"].Value = cSPN_tb.Text;
cmd.Parameters["@cSPS"].Value = cSPS_tb.Text;
cmd.Parameters["@cDate"].Value =
Convert.ToDateTime(cDate_tb.Text).ToShortDateString();
...
I used to recieve the error:
Error Code: 80020005
Message: Data conversion failed. [OLE DB status value,,,,,,]

I moved the @cDate paramater right after the @cDOB and everything seemed to
sort itself.

I still have no idea?

SSP


Alex Feinman said:
Why are you converting this to string before setting the param value?

What happens if you do this:

cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))

cmd.Parameters["@cDateReg"].Value = DateTime.Parse(cDateReg_tb.Text).Date;
cmd.Parameters["@cDate"].Value = DateTime.Parse(cDate_tb.Text).Date;

How is your table declared?

SSP said:
cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))

cmd.Parameters["@cDateReg"].Value =
Convert.ToDateTime(cDateReg_tb.Text).ToShortDateString();
cmd.Parameters["@cDate"].Value =
Convert.ToDateTime(cDate_tb.Text).ToShortDateString();

Error Code: 80020005
Message: Data conversion failed. [OLE DB status value,,,,,,]

This is typical of the crap I am going through at the moment! If it
works
in
one instance why won't it work in another??

SSP
 
CREATE TABLE tblChecklist (clCustomerName nvarchar (50), clMobileNo int, cl1
bit, cl2 bit, cl17 nvarchar (50), clSalesRepName nvarchar (50),
clSalesRepSig nvarchar (50), clSalesRepDate datetime, clCustSigName nvarchar
(50), clCustSig nvarchar (50), clCustDate datetime)


Alex Feinman said:
Could you post the structure of your data table?

SSP said:
If I don't convert it then I get a "conversion failed" type of error.

Here's the interesting bit. This used to be the setup:
...
cmd.Parameters.Add(new SqlCeParameter("@cDOB", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cSPN", DbType.String));
cmd.Parameters.Add(new SqlCeParameter("@cSPS", DbType.String));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date));
...
cmd.Parameters["@cDOB"].Value =
Convert.ToDateTime(cDOB_tb.Text).ToShortDateString();
cmd.Parameters["@cSPN"].Value = cSPN_tb.Text;
cmd.Parameters["@cSPS"].Value = cSPS_tb.Text;
cmd.Parameters["@cDate"].Value =
Convert.ToDateTime(cDate_tb.Text).ToShortDateString();
...
I used to recieve the error:
Error Code: 80020005
Message: Data conversion failed. [OLE DB status value,,,,,,]

I moved the @cDate paramater right after the @cDOB and everything seemed to
sort itself.

I still have no idea?

SSP


Alex Feinman said:
Why are you converting this to string before setting the param value?

What happens if you do this:

cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))

cmd.Parameters["@cDateReg"].Value = DateTime.Parse(cDateReg_tb.Text).Date;
cmd.Parameters["@cDate"].Value = DateTime.Parse(cDate_tb.Text).Date;

How is your table declared?

cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))

cmd.Parameters["@cDateReg"].Value =
Convert.ToDateTime(cDateReg_tb.Text).ToShortDateString();
cmd.Parameters["@cDate"].Value =
Convert.ToDateTime(cDate_tb.Text).ToShortDateString();

Error Code: 80020005
Message: Data conversion failed. [OLE DB status value,,,,,,]

This is typical of the crap I am going through at the moment! If it works
in
one instance why won't it work in another??

SSP
 
The following code works for me. Pls try it and reply back.

ssce = new SqlCeEngine(conStr);
if (File.Exists(sDBName)) File.Delete(sDBName);
ssce.CreateDatabase();

conn = new SqlCeConnection(conStr);
conn.Open();
cmd = conn.CreateCommand();
ExecuteSQL (cmd, "create table fooidx (col1 datetime, col2
nchar, col3 nchar, col4 datetime)");
ExecuteSQL (cmd, "insert into fooidx values (2/1/2003, '1',
'1', 2/1/2003)");

cmd.CommandText = "INSERT INTO fooidx VALUES(?, ?, ?, ?)";
SqlCeParameter p1 = cmd.Parameters.Add("col1", SqlDbType.DateTime);
SqlCeParameter p2 = cmd.Parameters.Add("col2", SqlDbType.NChar);
SqlCeParameter p3 = cmd.Parameters.Add("col3", SqlDbType.NChar);
SqlCeParameter p4 = cmd.Parameters.Add("col4", SqlDbType.DateTime);

p1.Value = Convert.ToDateTime("1/1/2001").ToShortDateString();
p2.Value = 'a';
p3.Value = 'b';
p4.Value = Convert.ToDateTime("1/1/2001").ToShortDateString();
cmd.ExecuteNonQuery();

Thanks,
Amy

--------------------
| From: "SSP" <[email protected]>
| References: <[email protected]>
<#[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: .NET CF extremely buggy!
| Date: Thu, 12 Feb 2004 22:56:08 +1200
| Lines: 85
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: duts5300-dialup5.is.com.fj 202.62.124.5
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:45558
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| CREATE TABLE tblChecklist (clCustomerName nvarchar (50), clMobileNo int,
cl1
| bit, cl2 bit, cl17 nvarchar (50), clSalesRepName nvarchar (50),
| clSalesRepSig nvarchar (50), clSalesRepDate datetime, clCustSigName
nvarchar
| (50), clCustSig nvarchar (50), clCustDate datetime)
|
|
| | > Could you post the structure of your data table?
| >
| > | > > If I don't convert it then I get a "conversion failed" type of error.
| > >
| > > Here's the interesting bit. This used to be the setup:
| > > ...
| > > cmd.Parameters.Add(new SqlCeParameter("@cDOB", DbType.Date));
| > > cmd.Parameters.Add(new SqlCeParameter("@cSPN", DbType.String));
| > > cmd.Parameters.Add(new SqlCeParameter("@cSPS", DbType.String));
| > > cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date));
| > > ...
| > > cmd.Parameters["@cDOB"].Value =
| > > Convert.ToDateTime(cDOB_tb.Text).ToShortDateString();
| > > cmd.Parameters["@cSPN"].Value = cSPN_tb.Text;
| > > cmd.Parameters["@cSPS"].Value = cSPS_tb.Text;
| > > cmd.Parameters["@cDate"].Value =
| > > Convert.ToDateTime(cDate_tb.Text).ToShortDateString();
| > > ...
| > > I used to recieve the error:
| > > Error Code: 80020005
| > > Message: Data conversion failed. [OLE DB status value,,,,,,]
| > >
| > > I moved the @cDate paramater right after the @cDOB and everything
seemed
| > to
| > > sort itself.
| > >
| > > I still have no idea?
| > >
| > > SSP
| > >
| > >
| > > | > > > Why are you converting this to string before setting the param
value?
| > > >
| > > > What happens if you do this:
| > > >
| > > > cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
| > > > cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))
| > > >
| > > > cmd.Parameters["@cDateReg"].Value =
| > DateTime.Parse(cDateReg_tb.Text).Date;
| > > > cmd.Parameters["@cDate"].Value = DateTime.Parse(cDate_tb.Text).Date;
| > > >
| > > > How is your table declared?
| > > >
| > > > | > > > > cmd.Parameters.Add(new SqlCeParameter("@cDateReg", DbType.Date));
| > > > > cmd.Parameters.Add(new SqlCeParameter("@cDate", DbType.Date))
| > > > >
| > > > > cmd.Parameters["@cDateReg"].Value =
| > > > > Convert.ToDateTime(cDateReg_tb.Text).ToShortDateString();
| > > > > cmd.Parameters["@cDate"].Value =
| > > > > Convert.ToDateTime(cDate_tb.Text).ToShortDateString();
| > > > >
| > > > > Error Code: 80020005
| > > > > Message: Data conversion failed. [OLE DB status value,,,,,,]
| > > > >
| > > > > This is typical of the crap I am going through at the moment! If
it
| > > works
| > > > in
| > > > > one instance why won't it work in another??
| > > > >
| > > > > SSP
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|
 
Back
Top