Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to disconnect and reconnect with a adodc control?

Status
Not open for further replies.

longmatch

Programmer
Nov 1, 2001
406
I am using adodc controls in my program. When the forms are loaded, the data will be automatically shown in the fields linked to the adodc control. But sometimes I do not need the fields in my form to connect to the database. How can I disconnect. If I have collected data in the fields, how to reconnect the link and store the data into the database?


Thanks.
 
You need to learn how to work with non binding your controls. I think that I had bound my controls the first year and never since. It's been ten years. Let me know if you need some help on Non-binding.

John
 
Dear John:
What does the non binding mean? If my understanding is correct, you use ADODC controls but do not bind the controls to the database. You bind the controls at the run time by writing code. Do you have any example to show your this technique. I do not need to adjust my programming strategy to make it more professional.

Your suggestion is very important to me. I do need to learn how to do that.

Thanks

Haijun
 
Haijun,

I believe what John was referring to was using code to connect to your data source.
I do this by means of the "Connection" object.
use this in conjunction with "Command" objects
and "Recordset" objects and you have much more control over the connection state than you do with ADODC.
You will need to know SQL to be able to do this well.
One way you can "cheat" is to create queries in Access that mimc what you want to accomplish and then cut & paste the SQL Access generates into your "Command" statement.

Hope this helps,

Brian
 
Hi Brian:
I understand what is the non-binding meaning right now. I tried to delete all of the ADODC controls in my application, and using coding instead binding controls to ADODC. I came across a problem, which maybe very simple to you. I do not know how to refer the recordset in other event. I wrote the code in my application (see below), how can I refer the recordset in my other command click event?
I declared and set the recordset in the general declaration area, which did not work. Still need your help. Thanks

Haijun

Dim strSQLDemo As String
Dim rsDemo As Recordset

strSQLDemo = "select * from tblDemographics"
Set rsDemo = getrs(strSQLDemo)

rsDemo.AddNew

rsDemo!MR = txtMR.Text
rsDemo!FirstName = txtPtFN.Text
rsDemo!LastName = txtPtLN.Text
rsDemo!DOB = txtDOB.Text
rsDemo!MF = cboSex.Text
rsDemo!Street = txtAddress.Text
rsDemo!city = txtCity.Text
rsDemo!State = txtState.Text
rsDemo!Zipcode = txtZIP.Text
rsDemo!homephone = txtHomePhone.Text
rsDemo!workphone = txtHomePhone.Text


fraDemographics.Visible = True

cmdDemoEdit.Enabled = False

 
Hi Append:
Thank you for your help. I forgot to tell that the function procedure to get recordset was put in my module. I forgot to put that in my last post. I can easily use your code into my application if I need update database. but if I need to save user's input on the form, how can I update my data. The recordset.addnew and recordset.update should be put in different procedures. Do I need recreate the recordset again. How can I do it without using ADODC?

Haijun
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top