I get unexpected error

  • Thread starter Thread starter amiga500
  • Start date Start date
A

amiga500

Private objConn As New SqlConnection("User
ID=DSUSER;PASSWORD=silentk;Data Source=10.12.0.8;Initial Catalog=Direct
Source System;Persist Security Info=False;Packet Size=4096")
Private objComm As SqlCommand = Nothing
Private objDataReader As SqlDataReader = Nothing
Private objCEConn As New SqlCeConnection("Data Source=\My
Documents\LocalTransfer\LocalDataBase.sdf")
Private objCEComm As SqlCeCommand = Nothing
Private objCEDataReader As SqlCeDataReader = Nothing
Private strSQL As String = ""
Private strCESQL As String = ""
Private strItemNumber As String = ""
Private strAlbumTitle As String = ""
Private strUPC As String = ""


' First we delete the table from scratch in case of errors

objCEConn.Open()
strCESQL = "DELETE FROM Products"
objCEComm = New SqlCeCommand(strCESQL, objCEConn)
objCEDataReader = objCEComm.ExecuteReader
objCEConn.Close()

objConn.Open()
tmrUpdate.Enabled = True


strSQL = "SELECT ItemNumber, AlbumTitle, UPC FROM Products"
objComm = New SqlCommand(strSQL, objConn)
objDataReader = objComm.ExecuteReader

While objDataReader.Read = True
strItemNumber =
Convert.ToString(objDataReader("ItemNumber"))
strAlbumTitle =
Convert.ToString(objDataReader("AlbumTitle"))
strUPC = Convert.ToString(objDataReader("UPC"))

If prgBar.Value >= prgBar.Maximum Then prgBar.Value = 0
prgBar.Value = prgBar.Value + 1
objCEConn.Open()
strCESQL = "INSERT INTO Products (ItemNumber,
AlbumTitle, UPC) VALUES ('" & strItemNumber & "','" & strAlbumTitle &
"','" & strUPC & "')"

Try
objCEComm = New SqlCeCommand(strCESQL, objCEConn)
objCEDataReader = objCEComm.ExecuteReader
Catch
MsgBox("Uh oh:" & Err.Description & ". Ignoring
error but that means some data is missing.")
Me.Close()
End Try
If prgBar.Value >= prgBar.Maximum Then prgBar.Value = 0
prgBar.Value = prgBar.Value + 1
Me.Refresh()
prgBar.Refresh()
objCEConn.Close()
End While
tmrUpdate.Enabled = False

objConn.Close()
MsgBox("Finished.")
Me.Close()

I don't understand everytime the line of code reaches here:

objCEDataReader = objCEComm.ExecuteReader

I get an "Unexpected error" no matter what. Can anyone help me please?
I don't know what to do. Thanks in advance. The file .sdf resides on my
mobile device, yesterday it worked fine, today I get this error. Any
help will be greatly appreciate, thanks in advance.
 
I resolved the problem by changing the name of the table but now I get
an error like this [ 1,74, S ] I know when such an error like this
occures it means that, this perticular record have been ignored. What
does this error mean? Any help will be greatly appreciate it thanks in
advance.
 
Back
Top