I'm taking an advanced VB course, and we are (trying) to learn to
connect a database to the application. However, even the instructor
is fumbling on some points, and things that should work according to
my two textbooks don't seem to. So, here's the situation. I have a
database for a hypothetical apartment complex, with two tables -- one
for renters, and one listing apartments.
1. I can set up the database connection string just fine as a design
time property of the ADODC control. However, it then seems "locked"
into the connection with the table specified in the ADODC Properties
dialog, on the RecordSource tab, in the Table Or Stored Procedure Name
field.
In other words, suppose on the ADODC Properties dialog I specify the
"RenterInfo" table as the RecordSource. If, in code, I then use the
line
adoMaster.RecordSource = "Apartments"
to change the record source, the program does not seem to recognize
this. As a result, I cannot access any of the fields in the
Apartments table.
(So, I CAN say frmMaster.txtFirstName.Text =
frmMaster.adoMaster.Recordset("FirstName")
but I cannot say
frmMaster.cboApt.Text = frmMaster.adoMaster.Recordset("Apt"),
since I can't seem to set the record source to the Apartments table.)
2. I thought maybe it would be better to delete the connection
information from the ADODC properties dialog, and specify it entirely
in code. This would also address the problem of hardcoding the
connection information to a specific location on my hard drive. The
code, based on the text, is:
adoMaster.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Persist Security Info=False;" & _
"Data Source=" & App.Path & "\LowHorizon.mdb"
adoMaster.CommandType = adCmdTable
adoMaster.RecordSource = "RenterInfo"
However, the program doesn't seem to acknowledge this at all. When I
use a command such as:
adoMaster.Recordset.MoveFirst
(or any other command with the RecordSet) I get an error: "Object
variable not set"
3. Also, if I want to bind a control to the database, at run time
rather than design time, I am having troubles with this too.
When I try to run the code:
txtFirst.DataSource = adoMaster
txtFirst.DataField = "First"
".DataSource" gets highlighted, and I get the message "Method or data
member not found. Yet DataSource is clearly a data member of a text
box!
4. Is there anyplace I can download some documentation on ADO and VB
in html, MS Word, or pdf format?
Help! And thanks.
Steve O.