Results 1 to 4 of 4

Thread: Please Help! SQLCE Error

  1. #1

    Thread Starter
    Junior Member Snizbatch's Avatar
    Join Date
    Sep 2002
    Location
    Jacksonville, FL
    Posts
    26

    Post Please Help! SQLCE Error

    Hi, I'm trying to change the data handling portion of an Application I'm writing for Windows Mobile 2003, to SQL rather than using a streamwriter. I'm receiving an error when trying to create a database.

    Here's the error:

    An unhandled exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll

    Additional information: SqlCeException

    Here's the code:

    VB Code:
    1. Dim dsAircraft As DataSet = Nothing
    2.         Dim daAircraft As SqlCeDataAdapter = Nothing
    3.         Dim ssceConn As SqlCeConnection = Nothing
    4.  
    5.         Dim DataPath As String = "Data Source=" & AppInfo.AppPath & "\aircraft.sdf"
    6.         If System.IO.File.Exists(AppInfo.AppPath & "\aircraft.sdf") = False Then
    7.             Dim engine As New SqlCeEngine(DataPath)
    8.             engine.CreateDatabase()         <--------------ERROR OCCURS HERE!
    9.         End If
    10.  
    11.         ssceConn = New SqlCeConnection(DataPath)
    12.         'Insert a new aircraft
    13.         Dim insertCommand As SqlCeCommand = ssceConn.CreateCommand()
    14.  
    15.         'Set the CommandText for the command
    16.         'The ?'s represent parameters that will be set later
    17.         insertCommand.CommandText = "Insert Into People(name, l_name) Values (?,?)"
    18.  
    19.         'Add parameters and assign them the values from the TextBoxes on the form
    20.         insertCommand.Parameters.Add(New SqlCeParameter("code", SqlDbType.NText, 10))
    21.         insertCommand.Parameters.Add(New SqlCeParameter("n_number", SqlDbType.NText, 8))
    22.         insertCommand.Parameters.Add(New SqlCeParameter("bow", SqlDbType.Decimal))
    23.         insertCommand.Parameters.Add(New SqlCeParameter("mac", SqlDbType.Decimal))
    24.         insertCommand.Parameters.Add(New SqlCeParameter("maxfuel", SqlDbType.Decimal))
    25.         insertCommand.Parameters.Add(New SqlCeParameter("hour1", SqlDbType.Decimal))
    26.         insertCommand.Parameters.Add(New SqlCeParameter("hour2", SqlDbType.Decimal))
    27.         insertCommand.Parameters.Add(New SqlCeParameter("hour3", SqlDbType.Decimal))
    28.         insertCommand.Parameters.Add(New SqlCeParameter("mgtow", SqlDbType.Decimal))
    29.  
    30.  
    31.         insertCommand.Parameters("code").Value = txtCode.Text
    32.         insertCommand.Parameters("n_number").Value = txtNNumber.Text
    33.         insertCommand.Parameters("bow").Value = txtBOW.Text
    34.         insertCommand.Parameters("mac").Value = txtMAC.Text
    35.         insertCommand.Parameters("maxfuel").Value = txtMaxFuel.Text
    36.         insertCommand.Parameters("hour1").Value = txtBurn1.Text
    37.         insertCommand.Parameters("hour2").Value = txtBurn2.Text
    38.         insertCommand.Parameters("hour3").Value = txtBurn3.Text
    39.         insertCommand.Parameters("mgtow").Value = txtMGTOW.Text
    40.  
    41.         btnAddAircraft.Enabled = False
    42.         ssceConn.Open()
    43.         insertCommand.ExecuteNonQuery()
    44.         ssceConn.Close()
    45.         btnAddAircraft.Enabled = True

    Any help would be appreciated!
    Thanks,
    Jim
    Last edited by Snizbatch; Jun 30th, 2006 at 07:33 PM. Reason: No Response

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Please Help! SQLCE Error

    Hi,
    what is the value in Appinfo.AppPath?

    Code looks ok - there is a sample at http://samples.gotdotnet.com/quickst...pactFramework/

    Pete

  3. #3

    Thread Starter
    Junior Member Snizbatch's Avatar
    Join Date
    Sep 2002
    Location
    Jacksonville, FL
    Posts
    26

    Re: Please Help! SQLCE Error

    I checked out my AppInfo.Path value... I put a watch on DataPath and it's coming up fine "Data Source=\Program Files\SDA4\aircraft.sdf"

    I noticed that my memory is dropping to about 11% when I run the program, maybe that's why?!?!?

    Grrrr


    Oh, and by the way... All the code I used is from that exact site you quoted above!

    Thanks,
    Jim

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Please Help! SQLCE Error

    You might try catching that specific type of exception, you generally get better info on the exception when you do this. Perhaps it would give you the key you need.

    You might consider putting the database on removable media, it is somewhat more durable, since the db won't go away on a hard restart, or low power issue.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width