|
-
Dec 6th, 2000, 05:05 AM
#1
Thread Starter
Lively Member
Hi.
I am having trouble with databases. I want to connect, open and set the recordset in code. Is this possible? i.e. Do I have to put the ADODC on the form? I presume it will be quicker and smaller to do it in code.
If I write it in code, how do I set the text fields to the correct field? And without the ADODC does .refresh etc work as normal?
I have set public connection/database/recordset names.
My current code is;
Code:
cnBSSAC.Open "provider=microsoft.jet.oledb.4.0;" & "Data Source=c:\database\bssac.mdb"
rstBSSAC.Open "commonBSSUser", dbBSSAC, adOpenKeyset, adLockPessimistic, adCmdTable
txtFields(3).DataSource = "commonBSSUser"
txtFields(3).DataField = "Name"
Thanks in advance,
Paul.
Set MCP = NTServer + NTWorkstation
-
Dec 6th, 2000, 05:17 AM
#2
Lively Member
You need to put an ADODC on the form and set its data source etc.. (you can make it invisible on the form)
to assign text fields do somthing like
Code:
with rstBSSAC
txtBox1.text = !FieldName1
txtBox2.text = !FieldName2
txtBox3.text = !FieldName3
txtBox4.text = !FieldName4
...
end with
as for .refresh etc.. they should still work but I'm not too sure about it.
H.
 Just trying to muddle through...
-
Dec 6th, 2000, 05:50 AM
#3
here it is
U can do it without having ADODC on the form. here it is..
for this u have to put Microsoft Activex Data Objects Refrences to ur project
code:
Option Explicit
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Form_Load()
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<database path>;Persist Security Info=False"
rs.Open "Select * from Employee", cn, adOpenKeyset, adLockOptimistic
rs.MoveFirst
Text1.Text=rs(0).value
Text1.Text=rs(1).value
Text1.Text=rs(2).value
End Sub
-
Dec 6th, 2000, 07:58 AM
#4
Thread Starter
Lively Member
Thanks guys..
Im actually making progress now.. 
Paul.
Set MCP = NTServer + NTWorkstation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|