Results 1 to 4 of 4

Thread: Please Help! SQLCE Error

Threaded View

  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

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