ADO.Net:unhandled exception...Help PLZ!!!!

sconineuk

New member
Joined
Mar 18, 2006
Messages
1
Programming Experience
Beginner
Can anyone help me please!! :confused:
I am just new to programming so this might sound rather trivial, but it has me stumped!
I have to search a database to see if a date is available for a booking to be made by the user. If the date they have chosen is already stored in the database a message must inform them that they can not have this date, else save their chosen date and other booking details into the database.
I have been able to connect to the DB and store details if the chosen date is not there but if the date is already there this error occurs and the application crashes:

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

This happens at the line which updates the adapter with the dataset. Here is a snippet of my code to see if anyone out there has a clue.
P.S. I have already tried a Try/Catch but this does not allow the user to then choose another date if their first date is in the DataBase.


'Sets a new row to be filled in the db
myRow = DsAllFields1.Bookings.NewBookingsRow

'sets a search of the database for the chosen date
Dim intRow As Integer
myConnection.Open()
DsAllFields1.Tables(0).DefaultView.Sort = "date"
intRow = DsAllFields1.Tables(0).DefaultView.Find("chosendate")
Debug.WriteLine(intRow)

If intRow < 0 Then
myRow("date") = chosendate
myRow("name") = OrgName
myRow("age") = orgAge
myRow("house number or name") = orgHouse
myRow("post code") = orgPostcode
myRow("phone number") = orgPhone
myRow("optionCode") = EventChoice

'fills the dataset with the user-input data
DsAllFields1.Bookings.Rows.Add(myRow)

'updates the adapter with the dataset items
Me.oleDABookinsAll.Update(DsAllFields1)
icon4.gif
'here that the error occurs

MessageBox.Show("Your date has been accepted and this booking has now been confirmed and stored. Thank you " & OrgName & "", MessageBoxButtons.OK)

'closes the connection with the database
myConnection.Close()

Else
MessageBox.Show(OrgName & " We are sorry but this date is not available for booking. You must now choose another.", "DATE UNAVAILABLE")
End If
 
You can get this type of exception for a variety of reasons useing OleDb, most likely it is a syntax problem with your parameters or in the SQL. Check and make sure you have all the fields, oledbtypes,tablename set correctly
 
Back
Top