|
-
Jun 4th, 2000, 08:14 PM
#1
Thread Starter
Member
data control binding??????????
Hi all
I want to know if I can achieve the followings when using an ADO control on the form:
Dim dbSe As Connection
Dim recSet2 As Recordset
Set dbSe = New Connection
dbSe.Provider = "msdasql"
dbSe.ConnectionString = "dsn=Xtreme sample" _
& "data;uid=sa;pwd=;"
dbSe.Open
Set recSet2 = New Recordset
recSet2.Open "select * from customer", dbSe, _
& adOpenDynamic, adLockPessimistic
txtFields.DataField = "Customer ID"
Set txtFields.DataSource = adoPrimaryRS
I got a ADO control on the form called 'adoRecset' which refers to a DSN and then for its recordset to a table call 'customer'.
-
Jun 4th, 2000, 10:32 PM
#2
Hyperactive Member
Try setting the textbox this way:
txtFields.text = adoRecset.customerID
-
Jun 4th, 2000, 10:53 PM
#3
Thread Starter
Member
No the porblem is that it complains that the object is not set and i am having problem 'opening' the 'adorecset' remember its an ado control on the form.
how do i
open it without binding any object directly becasue as soon as you bind any object ie bind a text box to the data control then it is opened,referenced and instantiated. but how do i get it to work just using source code.
-
Jun 5th, 2000, 09:53 PM
#4
Thread Starter
Member
-
Jun 6th, 2000, 12:11 PM
#5
Guru
so you want to bind a textbox to a recordset object, and NOT a data control?
-
Jun 6th, 2000, 03:37 PM
#6
Thread Starter
Member
actually Clunietp I want to bind it to data control binding it to a recordset object is already done see my code above.
Maybe if we forget the textbox and just say once you have assigned a DSN and a table to your ADO control then :
How do i using source code open the ado data control connection so its recordset is set and ready to be used?
-
Jun 6th, 2000, 10:04 PM
#7
Guru
Originally posted by sultan
How do i using source code open the ado data control connection so its recordset is set and ready to be used?
huh? the recordset is set and ready to be used when your form loads and the data control populates itself....
I must be missing your ultimate goal here....
-
Jun 6th, 2000, 10:24 PM
#8
Thread Starter
Member
Thanks Clunietp
1) Drag one ADO data control onto form.
2) Drag one textbox onto form.
3) Set the ADO control's ADODC property and choose an appropriate DSN for its ODBC data source name then choose a table for its record source.
4) Leave all the properties of the text box default at design time.
Now using source code bind the text box to the ado data control.
ie
txtbox1.DataField = "Customer ID"
Set txtbox1.DataSource = adoDataControl
-
Jun 7th, 2000, 09:14 AM
#9
Guru
OK
I put this into form_load:
Code:
Private Sub Form_Load()
Text1.DataField = "CustomerID"
Set Text1.DataSource = Me.Adodc1
End Sub
It works fine, the textbox is bound to the data control
I set the connection string of the data control and put in a recordsource
-
Jun 7th, 2000, 10:02 PM
#10
Thread Starter
Member
Many thanks Clunietp
The silly thing works for me as well but I can almost swear the same combination of code failed everytime I tried it in the past!!
WHAT IF I don't want to use any of the controls including the text box how can you access the record set that i want using the ADO Control.
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
|