SqlServerCE and InsertInto

  • Thread starter Thread starter Zanna
  • Start date Start date
Z

Zanna

Hi!

I've a big problem with SqlServerCE: If I do a loop of InsertInto (I create
the SQL and then do a SqlCeCommand.ExecuteNonQuery) it seems that if the
"insert" contains much data, sometimes my app crashes or just the insertinto
is not executed (I'm sure the data can be stored into the table).

I cannot even debug it because I got a "native exception" (code 0xc0000005:
someone know it?) and it crashes :(

Some tips on it?

Thanks

BTW: SqlServerCE has no SP?

Thanks!
 
Hi is it a consistent error or you just get once a while. Well as you
have not posted your code i can't make out what exactly the problem
may be, you can put try.. catch block and get the exact error. I'm
posting one general method for inserting into database , just call
this function passing your Insert Query and see if it works. IN case
it does not please send me your code so that i can have a look.

Public Function InsertIntoDatabase(ByVal t_strSQL As String) As
Boolean

Dim dbCommand As SqlCeCommand

Try

dbCommand = dbCN.CreateCommand()

dbCommand.CommandText = t_strSQL

dbCommand.ExecuteNonQuery()

InsertIntoDatabase = True


Catch ex As SqlCeException
For Each er As SqlCeError In ex.Errors
MsgBox(er.ToString())
Next er
Catch ex As InvalidCastException
'--- This will catch Cast exceptions
MsgBox(ex.ToString())
Catch ex As Exception
'--- This will catch any possible errors.
MsgBox(ex.ToString())

Finally
'--- Make sure to use IsNothing or Is Nothing when in
Finally,you will get
' "Object Reference" errors if you dont. Dispose
command object.
If IsNothing(dbCommand) = False Then dbCommand.Dispose()

End Try

End Function

Thanks

Anamika
 
anamika said:
Hi is it a consistent error or you just get once a while.

I get it often... too often.

Well as you
have not posted your code i can't make out what exactly the problem
may be, you can put try.. catch block and get the exact error.

I cannot trap the try because it is a native exception!
It is generated into the framework itself and is not trappable. :(

see http://www.neodatatype.net/dump/error1.jpg and
http://www.neodatatype.net/dump/error2.jpg
I'm
posting one general method for inserting into database , just call
this function passing your Insert Query and see if it works. IN case
it does not please send me your code so that i can have a look.

This is exactly the code I used.

Thanks.
 
Back
Top