Hi
Suppose your database has a table called [Screen] which has columns called
[ScreenID] and [SeatID].
Try this:
Public Sub GetSeatIDs(ByVal Screen As Int32, ByVal DBPath As String,
Optional ByVal DBPassword As String = "")
Dim oleConn As New OleDbConnection
Dim oleCSB As New OleDbConnectionStringBuilder
Dim oleAdapter As New OleDbDataAdapter
Dim dtSeatIDs As New DataTable
Dim arSeatIDs(0) As Int16
'build the connection string
With oleCSB
.Add("Provider", "Microsoft.Jet.OLEDB.4.0")
.Add("Data Source", DBPath)
.PersistSecurityInfo = True
If DBPassword <> "" Then
.Add("Jet OLEDB
atabase Password", DBPassword)
End If
End With
'associate the connection string just built with the ole connection
oleConn.ConnectionString = oleCSB.ConnectionString
'set up the data adapter with the sql to retrieve the data
oleAdapter.SelectCommand = New OleDbCommand("SELECT [SeatID] FROM
[Screen] WHERE [ScreenID]=" & Screen)
'associate the adapter with the connection to the database
oleAdapter.SelectCommand.Connection = oleConn
'open the connection
oleConn.Open()
'call the fill command to get the data into the datatable
oleAdapter.Fill(dtSeatIDs)
'copy the data into the array
'(although it might be easier to work with it still in the datatable)
dtSeatIDs.Rows.CopyTo(arSeatIDs, 0)
End Sub
hth
GC
Fabiyi Olawale said:
Please i'm new in VB.net and i'm designing a Cinema booking and purchase
system..I need to load the seat ID from the database into an array.please
how do i go about it.. or can anyone give me an idea of how i can show seats
are availabele,booked or bought..i'll really appreciate input....
regards
wale fabiyi
Kuala Lumpur,Malaysia- Hide quoted text -
- Show quoted text -