Database questions

Just starting out? Need help? Post your questions and find answers here.
David
User
User
Posts: 14
Joined: Sat Mar 05, 2005 11:23 am

Database questions

Post by David »

Hi.

I am switching from VB to PB but I am having trouble understanding how you retrieve data from access databases in PB. For example, is there a PB equivalent for the following snippet?

-------------------------------

Set oRS = New Recordset
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0" & ";Data Source=" & App.Path & "\Database.mdb"
strSQL = "SELECT Field FROM Table"
oRS.Open strSQL, strConnect, adOpenForwardOnly, adLockReadOnly
Do Until oRS.EOF
If Len(oRS.Collect("Field")) > 0 Then
lstListBox.AddItem oRS.Collect("Field")
End If
oRS.MoveNext
Loop
oRS.Close
Set oRS = Nothing

-------------------------------

I won't ask too many questions here while I am learning but this would be very helpful. Thank you.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Take a look at Database.pb in the Examples\sources folder.

One major restriction is that you can only access a database through a DSN. You cannot use a connection string in your code.

You create DSNs in the control panel's data sources. The example program opens the data source dialog for you.
David
User
User
Posts: 14
Joined: Sat Mar 05, 2005 11:23 am

Post by David »

Yes, that works ok. Thank you GedB.
Post Reply