Getting new data into my SQLCe database

  • Thread starter Thread starter Atley
  • Start date Start date
A

Atley

When I use the example below, I get the exact same results I got from
mine.... It appears to do nothing, then when I try to close my app, I get a
cast exception error. I am using try...catch to get the error, but I am
getting nothing. what in the world am I doing wrong?

I liked the good old days of hooking to a recordset, plugging in my values
and then closing the recordset... Does that not exist in SQLCe?

I can get data in if I use a standard insert statement and load it, the
weakness here is that my ntext field contains carriage returns and
apostrophes, this negates the process of creating an INSERT string and
running it. The parameter method just doesn't seem to work for me, at all.

This UPDATE/INSERT crap is just not cutting it here, I can do this fine with
SQL Server, have been for years, but the Ce version seems cut off at the
knees, I have been working on this simple stupid statement all week (not
full time mind you), it is the last of one or two problems I have been
having and it is driving me bonkers!

Also, I am sorry for posting this in a new thread, but my old one seems to
have died.

Anyone have any ideas, or maybe a new method I can try?

Thanks in advance for your help...

Atley



strSQL = "INSERT INTO StoreCall (a, b, c, d, e, f) " & _
" VALUES (?,?,?,?,?,?)"

sqlCMD = New SqlServerCe.SqlCeCommand
With sqlCMD .CommandText = strSQL
.Connection = m_sqlCN
.Parameters.Add("@a", SqlDbType.Int).Value = m_intStoreID
.Parameters.Add("@b", SqlDbType.DateTime).Value = dteStart
.Parameters.Add("@c", SqlDbType.DateTime).Value = dteEnd
.Parameters.Add("@d", SqlDbType.NText).Value = strComment
.Parameters.Add("@e", SqlDbType.Int).Value = intCycleID
.Parameters.Add("@f", SqlDbType.Bit).Value = blnIsDMCall
.Prepare()
.ExecuteNonQuery()
End With
 
Hi,

The code looks ok, except for one syntax error: Instead of "With
sqlCMD.CommandText", it should be "With sqlCMD". But I'm sure that's just a
typo in the post.

What is cast exception that you are getting? I suspect it might be a
problem with the format of date fields. I would try substituting hard-coded
values to rule that out, for example:
Parameters.Add("@b", SqlDbType.DateTime).Value = "1/1/2000"

Let me know if that helps.

Thanks,
Tomer
Microsoft SQL Server CE Team
 
Back
Top