Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Data Control to ADO Code

Posted on 2007-07-26
6
Medium Priority
?
268 Views
Last Modified: 2010-04-09
How would you turn this into ADO code?

If Data1.Database.TableDefs("DBRecords").Name <> "DBRecords" Then create_dbrecords
If Data1.Database.TableDefs("musicians").Name <> "musicians" Then musicians
If Data1.Database.TableDefs("all_users").Fields("Birthday").Name <> "Birthday" Then UpgradeMDB
If Data1.Database.TableDefs("all_users").Fields("Music").Name <> "Music" Then UpgradeMDBII
If Data1.Database.TableDefs("email_offline").Name <> "email_offline" Then Email_Offline
If Data1.Database.TableDefs("event_invite").Name <> "event_invite" Then Event_Invite
If Data1.Database.TableDefs("advert_via_event_log").Name <> "advert_via_event_log" Then advert_via_event_log
If Data1.Database.TableDefs("live_shows").Name <> "live_shows" Then live_shows
0
Comment
Question by:Takamine334
6 Comments
 
LVL 10

Expert Comment

by:Clif
ID: 19577884
You would need to create a database object, open it to the correct database, and then search and replace "Data1.Database" with the name od the database object:

Dim MyDB As Database
Set MyDB = OpenDatabase("c:\myAccessDB.mdb")
If MyDB.TableDefs("DBRecords").Name <> "DBRecords" Then create_dbrecords
If MyDB.TableDefs("musicians").Name <> "musicians" Then musicians
If MyDB.TableDefs("all_users").Fields("Birthday").Name <> "Birthday" Then UpgradeMDB
If MyDB.TableDefs("all_users").Fields("Music").Name <> "Music" Then UpgradeMDBII
If MyDB.TableDefs("email_offline").Name <> "email_offline" Then Email_Offline
If MyDB.TableDefs("event_invite").Name <> "event_invite" Then Event_Invite
If MyDB.TableDefs("advert_via_event_log").Name <> "advert_via_event_log" Then advert_via_event_log
If MyDB.TableDefs("live_shows").Name <> "live_shows" Then live_shows
0
 

Author Comment

by:Takamine334
ID: 19577939
oh, that's it? for ADO code?
0
 
LVL 10

Expert Comment

by:Clif
ID: 19578069
Oh, heck.  What was I thinking...

Sorry about that.  It's late in the day.  :(
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Takamine334
ID: 19578998
So, thats not the answer? Guess not.
0
 
LVL 12

Accepted Solution

by:
jkaios earned 1000 total points
ID: 19580292
Use both ADO and ADOX to accomplish this.

1. Add "Microsoft ActiveX Data Objects 2.x Library" and "Microsoft ADO Ext. 2.x for DDL and Security" via the Projects->References menu.

2. Copy sample code below into a new project and run it.


Option Explicit

Private Sub Form_Load()

   Dim oCN As New ADODB.Connection
   Dim oRS As New ADODB.Recordset
   
   With oCN
      .Provider = "Microsoft.JET.OLEDB.4.0"
      .Properties("Data Source") = "C:\YOURDB.MDB"       '<== CHANGE THIS TO YOUR ACTUAL DB NAME AND PATH
      .Open
   End With
   
   If oCN.State = adStateOpen Then
      showTables oCN
   End If

End Sub

Private Sub showTables(oCN As ADODB.Connection)

   Dim oCat As New ADOX.Catalog
   Dim oTbl As New ADOX.Table
   
   oCat.ActiveConnection = oCN
   
   '--- For Each oTbl In oCat.Tables
   '---   Debug.Print oTbl.Name, oTbl.Type
   '--- Next
   
   If oCat("DBRecords").Name <> "DBRecords" Then Debug.Print "create_dbrecords"
   If oCat("musicians").Name <> "musicians" Then  Debug.Print "musicians"
   If oCat("all_users").Columns("Birthday").Name <> "Birthday" Then  Debug.Print "UpgradeMDB"
   If oCat("all_users").Columns("Music").Name <> "Music" Then  Debug.Print "UpgradeMDBII"
   If oCat("email_offline").Name <> "email_offline" Then  Debug.Print "Email_Offline"
   If oCat("event_invite").Name <> "event_invite" Then  Debug.Print "Event_Invite"
   If oCat("advert_via_event_log").Name <> "advert_via_event_log" Then  Debug.Print "advert_via_event_log"
   If oCat("live_shows").Name <> "live_shows" Then  Debug.Print "live_shows"
   
End Sub
0
 
LVL 14

Assisted Solution

by:bugs021997
bugs021997 earned 1000 total points
ID: 19580298
<%
Dim myConn
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open = ("DRIVER={Microsoft Access" &_
" Driver (*.mdb)};DBQ=" &_
"C:\myAccessDB.mdb;")

strSQL="SELECT * FROM YOUR TABLE"
set rs = server.createObject("ADODB.Recordset")
rs.open strSQL, db, 2, 2

If rs("COLUMN_NAME") <> "CONDITION" Then create_dbrecords
//PUT ALL YOUR CODITIONS HERE...



rs.close
set rs=nothing

myConn.Close()
Set myConn = nothing

%>
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

564 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