database - How to fetch record from two Ms.Access tables in Visual Studio 2010? -
i making railway reservation system in want user see booking history. in reservation system there multiple login facility . many users can create account , book tickets . so, user can check bookings made account . due reason , thought should compare username of opened account account username column present in database . if username of opened account matches account username in database , fetch records under name when try execute, gives me error.
imports system.data.oledb public class form12 dim connstring string = "provider=microsoft.ace.oledb.12.0; data source=c:\users\amen\documents\railway.accdb" dim myconn oledbconnection dim da oledbdataadapter dim ds dataset dim tables datatablecollection dim source1 new bindingsource private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click myconn = new oledbconnection myconn.connectionstring = connstring ds = new dataset tables = ds.tables da = new oledbdataadapter("select [t.tnumber], [t.p_name], [t.age],[t.train_name], [t.seat_no], [t.berth],[t.r_name], [t.starting_point],[t.destination], [t.departure], [t.arrival], [t.fare] table2 ,table1 t.pnr_number=t.pnr_number , t.account_user=my.settings.username", myconn) da.fill(ds, "table2") dim view new dataview(tables(0)) source1.datasource = view datagridview1.datasource = view end sub end class
i think wrong da.fill(ds, "table2") don't know how correct it.
in select
statement comparing against my.settings.username, , imagining string doesn't exist in db. want value inside my.settings.username, can use string concatenation add end (as long string!).
da = new oledbdataadapter("select [t.tnumber], [t.p_name], [t.age],[t.train_name], [t.seat_no], [t.berth],[t.r_name], [t.starting_point],[t.destination], [t.departure], [t.arrival], [t.fare] table2 ,table1 t.pnr_number=t.pnr_number , t.account_user=" + my.settings.username, myconn)
Comments
Post a Comment