Results 1 to 10 of 10

Thread: Database/Project Problems

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    12

    Database/Project Problems

    Hey,

    for my project i have to create a program for a travel agency. i've got most of the program working but im having big problems writing to my database. What i don't understand is that i can read from it with out any problems but when i try to write to it i keep getting errors. The debugging error keeps coming up when i execute this line "objDetails.Update(objDataSet, "Customers")". the debuggin error i get is " An unhandled exception of type 'System.Data.OleDb.OleDbExecption' occurred in system.data.dll ". ive attached part of my program on a zip file. the error coomes up on two forms "CustDetails.vb" and "Customers.vb". the error comes up at pretty much the same point, when im writing to the database. if anyother information is needed to help me fix this please post me back

    thanks for any help at all

    Mike
    Last edited by michaeln31; Apr 25th, 2006 at 01:42 PM.

  2. #2
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: Database/Project Problems

    Are you using SQL 2000?

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    12

    Re: Database/Project Problems

    No, Microsoft Office Access 2003. the databasse is included in the bin folder on the attachment

  4. #4
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: Database/Project Problems

    I would like to help you but I don't like to download files or attachments.

    Could you post your codes?

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    12

    Re: Database/Project Problems

    Yah sure. this code is for the CustDetails.vb form. the error comes up at the end when "objDetails.Update(objDataSet, "Customers")" is executed. if u want i can post the other form up aswell.

    Public Class CustDetails
    Inherits System.Windows.Forms.Form

    Dim confirm As New confirmation


    Dim objConnection As New OleDb.OleDbConnection( _
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= project.mdb")
    Dim objDetails As New OleDb.OleDbDataAdapter("Select * From Customers", objConnection)
    Dim objDetails2 As New OleDb.OleDbCommandBuilder(objDetails)
    Dim objDataSet As New DataSet
    Public Sub Retrieve()

    objDataSet.Clear()
    objDetails.FillSchema(objDataSet, SchemaType.Source, "Customers")
    objDetails.Fill(objDataSet, "Customers")

    End Sub

    Private Sub CmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSave.Click
    Dim ta_main As New TravelAgentMain

    Retrieve()

    Dim objRow As DataRow

    Dim strCustomerID As String
    Dim strTitle As String
    Dim strFname As String
    Dim strLname As String
    Dim strAddress As String
    Dim strCounty As String
    Dim strTele As String
    Dim strEmail As String
    Dim strFreqFlyer As String
    Dim strFlightID1 As String
    Dim strFlightID2 As String
    Dim strNoPassengers As String
    Dim strTotalCost As String
    Dim strRemainingBalance As String

    strCustomerID = txtCustPassword.Text
    strTitle = CustTitle.Text
    strFname = txtCustFore.Text
    strLname = txtCustSur.Text
    strAddress = txtCustAdd.Text
    strCounty = CustCounty.Text
    strEmail = txtCustEmail.Text
    strTele = txtCustTele.Text

    strFlightID1 = Confirmation.FlightIDOut.Text
    strFlightID2 = Confirmation.FlightIDRet.Text
    strNoPassengers = Confirmation.NoPassengers.Text
    strTotalCost = confirm.TotalPrice.Text
    strRemainingBalance = confirm.TotalPrice.Text

    If FrqFly.Visible = False Then
    strFreqFlyer = "0"

    ElseIf FrqFly.Visible = True Then
    strFreqFlyer = txtCustNumber.Text
    End If

    objRow = objDataSet.Tables("Customers").NewRow

    objRow.Item("CustomerID") = strCustomerID
    objRow.Item("Title") = strTitle
    objRow.Item("Fname") = strFname
    objRow.Item("Lname") = strLname
    objRow.Item("Address") = strAddress
    objRow.Item("County") = strCounty
    objRow.Item("TelephoneNumber") = strTele
    objRow.Item("EmailAddress") = strEmail
    objRow.Item("Frequent Flyer Number") = strFreqFlyer
    objRow.Item("FlightID1") = strFlightID1
    objRow.Item("FlightID2") = strFlightID2
    objRow.Item("Number Of Passengers") = strNoPassengers
    objRow.Item("TotalCost") = strTotalCost
    objRow.Item("RemainingBalance") = strRemainingBalance

    objDataSet.Tables("Customers").Rows.Add(objRow)
    objDetails.Update(objDataSet, "Customers")


    Me.Hide()
    ta_main.Show()
    Me.Close()

    End Sub

    Private Sub CmdBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdBack.Click
    Dim booking As New BookingForm
    Me.Hide()
    booking.Show()

    End Sub

    Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
    Dim main As New MainScreen

    Me.Hide()
    main.Show()
    Me.Close()

    End Sub

    Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
    Dim ta_main As New TravelAgentMain

    Me.Hide()
    ta_main.Show()
    Me.Close()
    End Sub

    Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
    Me.Hide()
    Me.Close()
    End
    End Sub

    Private Sub CustDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If confirm.Standard.Checked = True Then
    FrqFly.Visible = False
    End If

    End Sub
    End Class

  6. #6
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: Database/Project Problems

    Try changing you objDetails.Update(Dataset,"Customer") to

    objDetails.Update(Dataset)

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    12

    Re: Database/Project Problems

    Yah i tried that yesterday thinking it was the "Customers" that was putting its off but i got a different error message. maybe you can understand it, it says " An unhandled execption of type 'System.InvalidOperationException' occurred in system.data.dll Additional information: Update unable to find TableMapping['Table'] or DataTable 'Table'"

  8. #8
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: Database/Project Problems

    Hmmm.... are you familiar about using update query.

  9. #9

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    12

    Re: Database/Project Problems

    no not at all. ive only started working with a database this week.

  10. #10

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    12

    Re: Database/Project Problems

    Never mind i fixed that problem. the error was in the names. when i removed the spaces in the database names it fixed the program. only thing is that i have another problem along the same lines. the same error comes up. Syntax error INSERT INTO statement.
    VB Code:
    1. Public Class AddRoute
    2.     Inherits System.Windows.Forms.Form
    3.     Dim objConnection As New OleDb.OleDbConnection( _
    4.                "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= project.mdb")
    5.  
    6.     Dim objFlightOut As New OleDb.OleDbDataAdapter("Select * from Outbounds", objConnection)
    7.     Dim objFlightOutCB As New OleDb.OleDbCommandBuilder(objFlightOut)
    8.     Dim objDataSetOut As New DataSet
    9.  
    10.     Dim objFlightRet As New OleDb.OleDbDataAdapter("Select * from Returnings", objConnection)
    11.     Dim objFlightRetCB As New OleDb.OleDbCommandBuilder(objFlightRet)
    12.     Dim objDataSetRet As New DataSet
    13.  
    14.    
    15.     Public Sub Retrieve()
    16.       objDataSetOut.Clear()
    17.  
    18.         objFlightOut.FillSchema(objDataSetOut, SchemaType.Source, "Outbounds")
    19.         objFlightOut.Fill(objDataSetOut, "Outbounds")
    20.  
    21.         objDataSetRet.Clear()
    22.  
    23.         objFlightRet.FillSchema(objDataSetRet, SchemaType.Source, "Returnings")
    24.         objFlightRet.Fill(objDataSetRet, "Returnings")
    25.  
    26.     End Sub
    27.  
    28. Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
    29.  
    30.  
    31.         Dim objRowOut As DataRow
    32.  
    33.  
    34.         Dim strSource As String = txtRouteFrom.Text
    35.         Dim strDestination As String = txtRouteTo.Text
    36.         Dim strDay1 As String = cboDay1.Text
    37.         Dim strMonth1 As String = cboMonth1.Text
    38.         Dim strDay2 As String = cboDay2.Text
    39.         Dim strMonth2 As String = cboMonth2.Text
    40.  
    41.         Dim strDepartDateOut As String
    42.         Dim strDepartTimeOut As String
    43.         Dim strArriveDateOut As String
    44.         Dim strArriveTimeOut As String
    45.  
    46.         Dim strDepartDateRet As String
    47.         Dim strDepartTimeRet As String
    48.         Dim strArriveDateRet As String
    49.         Dim strArriveTimeRet As String
    50.  
    51.         strDepartDateOut = txtDepartDateOut.Text
    52.         strDepartTimeOut = txtDepartTimeOut.Text
    53.         strArriveDateOut = txtArriveDateOut.Text
    54.         strArriveTimeOut = txtArriveTimeOut.Text
    55.  
    56.         strDepartDateRet = txtDepartDateRet.Text
    57.         strDepartTimeRet = txtDepartTimeRet.Text
    58.         strArriveDateRet = txtArriveDateRet.Text
    59.         strArriveTimeRet = txtArriveTimeRet.Text
    60.  
    61.         Retrieve()
    62.  
    63.         objRowOut = objDataSetOut.Tables("Outbounds").NewRow
    64.  
    65.         objRowOut.Item("Source") = strSource
    66.         objRowOut.Item("Destination") = strDestination
    67.         objRowOut.Item("Day") = strDay1
    68.         objRowOut.Item("Month") = strMonth1
    69.         objRowOut.Item("DepartureDate") = strDepartDateOut
    70.         objRowOut.Item("DepartureTime") = strDepartTimeOut
    71.         objRowOut.Item("ArrivalDate") = strArriveTimeOut
    72.         objRowOut.Item("ArrivalTime") = strArriveTimeOut
    73.  
    74.  
    75.         objDataSetOut.Tables("Outbounds").Rows.Add(objRowOut)
    76.         Try
    77.  
    78.             objFlightOut.Update(objDataSetOut, "Outbounds")
    79.  
    80.         Catch ex As Exception
    81.  
    82.             MessageBox.Show(ex.Message)
    83.  
    84.         End Try
    85.  
    86.         Dim objRowRet As DataRow
    87.  
    88.         objRowRet = objDataSetRet.Tables("Returnings").NewRow
    89.  
    90.         objRowRet.Item("Source") = strDestination
    91.         objRowRet.Item("Destination") = strSource
    92.         objRowRet.Item("Day") = strDay2
    93.         objRowRet.Item("Month") = strMonth2
    94.         objRowRet.Item("DepartureDate") = strDepartDateRet
    95.         objRowRet.Item("DepartureTime") = strDepartTimeRet
    96.         objRowRet.Item("ArrivalDate") = strArriveDateRet
    97.         objRowRet.Item("ArrivalTime") = strArriveTimeRet
    98.  
    99.         objDataSetRet.Tables("Returnings").Rows.Add(objRowRet)
    100.         Try
    101.  
    102.  
    103.         objFlightRet.Update(objDataSetRet, "Returnings")
    104.  
    105.         Catch ex As Exception
    106.  
    107.         MessageBox.Show(ex.Message)
    108.  
    109.         End Try
    110.  
    111.         Dim admin As New AdminMain
    112.  
    113.         Me.Hide()
    114.         admin.Show()
    115.         Me.Close()
    116.  
    117.     End Sub

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