Hello ! I am making a project on Railway reservation system in which I want the user should have access to his booking history . In my project , many people can have accounts . A user can also view his booking history . So , for that a user enters his phone number and that number will be used to match against the records which the user wants to view. The following code access records from two tables in the database . When I run this code for only one table ( accessing records from one table ) , it works fine but when I run this code for two tables , it gives me an error saying OleDbexception was unhandled .
[/COLOR][COLOR=#333333]Using cmd As OleDbCommand = MyConn.CreateCommand[/COLOR] ds = New DataSet tables = ds.Tables Using da As New OleDbDataAdapter cmd.CommandText = "Select P.Tnumber,P.Name ,P.Age ,T.PNR_Number,P.Train_Name ,P.SeatNo ,P.Berth ,P.Coach_Number, T.Starting_Point , T.Destination , T.Departure , T.Arrival , T.Fare From Table1 As P INNER JOIN Table2 As T ON P.Train_Name = T.Train_Name WHERE P.Phone = ?" Try cmd.Parameters.AddWithValue("p1", TextBox1.Text) da.SelectCommand = cmd da.Fill(ds, "Table2") Dim view As New DataView(tables(0)) source1.DataSource = view DataGridView1.DataSource = view Catch ex As Exception MsgBox(ex.Message) End Try End Using End Using