Dim dsAircraft As DataSet = Nothing
Dim daAircraft As SqlCeDataAdapter = Nothing
Dim ssceConn As SqlCeConnection = Nothing
Dim DataPath As String = "Data Source=" & AppInfo.AppPath & "\aircraft.sdf"
If System.IO.File.Exists(AppInfo.AppPath & "\aircraft.sdf") = False Then
Dim engine As New SqlCeEngine(DataPath)
engine.CreateDatabase() <--------------ERROR OCCURS HERE!
End If
ssceConn = New SqlCeConnection(DataPath)
'Insert a new aircraft
Dim insertCommand As SqlCeCommand = ssceConn.CreateCommand()
'Set the CommandText for the command
'The ?'s represent parameters that will be set later
insertCommand.CommandText = "Insert Into People(name, l_name) Values (?,?)"
'Add parameters and assign them the values from the TextBoxes on the form
insertCommand.Parameters.Add(New SqlCeParameter("code", SqlDbType.NText, 10))
insertCommand.Parameters.Add(New SqlCeParameter("n_number", SqlDbType.NText, 8))
insertCommand.Parameters.Add(New SqlCeParameter("bow", SqlDbType.Decimal))
insertCommand.Parameters.Add(New SqlCeParameter("mac", SqlDbType.Decimal))
insertCommand.Parameters.Add(New SqlCeParameter("maxfuel", SqlDbType.Decimal))
insertCommand.Parameters.Add(New SqlCeParameter("hour1", SqlDbType.Decimal))
insertCommand.Parameters.Add(New SqlCeParameter("hour2", SqlDbType.Decimal))
insertCommand.Parameters.Add(New SqlCeParameter("hour3", SqlDbType.Decimal))
insertCommand.Parameters.Add(New SqlCeParameter("mgtow", SqlDbType.Decimal))
insertCommand.Parameters("code").Value = txtCode.Text
insertCommand.Parameters("n_number").Value = txtNNumber.Text
insertCommand.Parameters("bow").Value = txtBOW.Text
insertCommand.Parameters("mac").Value = txtMAC.Text
insertCommand.Parameters("maxfuel").Value = txtMaxFuel.Text
insertCommand.Parameters("hour1").Value = txtBurn1.Text
insertCommand.Parameters("hour2").Value = txtBurn2.Text
insertCommand.Parameters("hour3").Value = txtBurn3.Text
insertCommand.Parameters("mgtow").Value = txtMGTOW.Text
btnAddAircraft.Enabled = False
ssceConn.Open()
insertCommand.ExecuteNonQuery()
ssceConn.Close()
btnAddAircraft.Enabled = True