[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

changing database connections

Posted on 2011-10-19
2
Medium Priority
?
295 Views
Last Modified: 2012-05-12
Hello experts,
I have a question that I hope you can help me with.
I have an application that was built a while ago in VB6 and an access database.  I would like to replace the adodc controls with code because I want to change the DB to MYsql.  
Here is my question:

When I wrote the app  i used a lot of data controls which I want to replace with code.
this is what I have now:

Private Sub Text7_Change()
'this section will display all pets encounters in dbgrid1 who's PetID
'equals the value of text 7.text(pet id field)in this case only today and future appointments
Dim PetEnc As String
PetEnc = ("select encounter_date,prelim,assessment,diagnosis,treatment,encounterID from encounter WHERE [PetID] = '" & Text7.Text & "'ORDER BY encounter_date  DESC ")
Adodc2.RecordSource = PetEnc
Adodc2.Refresh
End Sub

This is what I am using to populate some list boxes and and would like to remove the data controls and use this code to populate the textboxes.
'****************************************************************
'*   'these load the listboxes with med Dosing information.
'****************************************************************

'-Create a new connection --
        Set adoConnection = New ADODB.Connection
                '-Create a new recordset --
        Set adoRecordset = New ADODB.Recordset
 '-Build the connection string to use when we open the connection --
        connectString = "Data Source=mariner;Database=food;Uid=""; Pwd="";"
        adoConnection.Open connectString
        adoRecordset.Open "SELECT * from MedDoseForm", adoConnection
'-Populate the listbox
          Do Until adoRecordset.EOF
          If adoRecordset!Form > "" Then List3.AddItem adoRecordset!Form 'Else: text14.Text = "1"
          adoRecordset.MoveNext
            Loop
adoRecordset.Close

my question here is, I know how to load the list boxes but how to I modify this to populate the textboxes when I remove the adodc controls? do I need to list each text box seperately?

sorry to be so wordy, and I hope you understand my questions the way I wrote them
Thanks in Advance !
0
Comment
Question by:Stevenj2
2 Comments
 
LVL 40

Accepted Solution

by:
Vadim Rapp earned 2000 total points
ID: 36999688
> I would like to replace the adodc controls with code because I want to change the DB to MYsql.  

Maybe this is not necessary; adodc control will accept any ADO connection; the provider for MySQL does exist, so maybe all you need to do is to adjust the connection string for adodc control. You can find connection string at http://www.connectionstrings.com/mysql#p27

>how to I modify this to populate the textboxes when I remove the adodc controls? do I need to list each text box seperately?

Yes, you do. Either the control is data-bound to Data Control, or you populate it in code.

0
 

Author Closing Comment

by:Stevenj2
ID: 37001454
ok then,  thank you very much !
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question