Hi All,
I have created a form for a user to create a booking of a meeting room, I need this form to do 3 things.
have print functionality
update the new booking to a dataset
view the current bookings screen
I seem to be struggling with the second task, when I try and save my new booking I get this error
System.InvalidOperationException was unhandled
Message="Update unable to find TableMapping['mtrbookings'] or DataTable 'mtrbookings'."
Please see the code for my form.
Imports System.Data.SqlClient
Public Class Form1
Dim conn As SqlConnection
Dim Bookings As SqlDataAdapter
Dim dsBookings As DataSet
Dim cmdBuilder As SqlCommandBuilder = New SqlCommandBuilder(Bookings)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
conn = New SqlConnection("Data Source=JOHN-ELLIS-PC;Initial Catalog=mtrbookings;Integrated Security=True")
conn.Open()
Catch ex As Exception
MessageBox.Show("CONNECTION FAILED" & ex.Message)
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Form2.Show()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dsBookings = New DataSet
Bookings = New SqlDataAdapter("SELECT BookingID,RoomID,UserID,BookDate,StartTime,EndTime,Reason FROM Bookings", conn)
Bookings.Update(dsBookings, "mtrbookings")
End Sub
End Class
My feeling is that I have not declaired any data sources, like a data grid view or the text boxes from which my information is typed by the user (text boxes).
Can anyone help.
Thanks very much
John