Advertisement

07.16.2008 at 03:25AM PDT, ID: 23569047
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

What i must change in this VBScript in order to connect to a mysql db instead of a file?

Asked by PredatorGR in VB Script, MySQL Server

Tags:

Hi, i have this code and i must use it to fetch data from mysql and not a local file. What i must change in order to achieve this?

I've converted the already existed file catalog.mdb to mysql and imported it via phpmyadmin. My mysql is local (localhost), username "root" and password "root", db name "test".


Thanks!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
Option explicit
 
'
' cc.vbs - This VBScript does an SQL query on a sample database, card catalog.mdb.
'
' This VBScript expects four variables exported from Scala:
'   
'   sSearchtype            tells the windows script what type of query this is.
'   sCriteria              tells the windows script what the search criteria is.
'   sQueryResult           Scala's array for the results of the query.
'   iTotal                 Gives Scala current result count from VB's perspective
'
 
Dim myConnection
Dim NameDataSet
Dim sSQL
Dim VBBSTRArray(1000)
Dim oScala
 
' Create an instance of the ScalaPlayer object to get at some useful functions
'
Set oScala = CreateObject("ScalaPlayer.ScalaPlayer.1")
 
' Create the ADO object to access the database
'
Set myConnection = CreateObject("ADODB.Connection")
 
' Open the database.  This connection string opens the database as a file (rather than using
' an ODBC DSN).  Notice that it presumes the database file, card catalog.mdb, can be found in the
' same directory as this VBScript.  Alternately, if the database had been installed as an
' ODBC User DSN called 'biblio' (using the control panel item "ODBC Data Sources"), the open 
' call might look like this:
'
' myConnection.Open "DSN=biblio"
'
myConnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & oScala.ScriptDir & "\card catalog.mdb"
 
 
' Put together the SQL query command.
'
sSQL = "select * from All_Titles "
 
'Narrow the search by a search type, and by a criteria
If (sSearchtype = "Title") Then
        sSQL = SSQL & "WHERE All_Titles.Title Like '%" & sCriteria & "%'"
 
Elseif (sSearchtype = "ISBN") Then
        sSQL = SSQL & "WHERE All_Titles.ISBN Like '%" & sCriteria & "%'"
 
ElseIf (sSearchtype = "Author") Then
        sSQL = SSQL & "WHERE All_Titles.Author Like '%" & sCriteria & "%'"
 
ElseIf (sSearchtype = "Year") Then
        sSQL = SSQL & "WHERE All_Titles.Year Like '%" & sCriteria & "%'"
	'sSQL = sSQL & "WHERE All_Titles.Year = " & sCriteria
 
Else
        sSQL = SSQL & "WHERE All_Titles.Publisher Like '%" & sCriteria & "%'"
End If
 
' Do the query and stick the results into NameDataSet
'
Set NameDataSet = myConnection.Execute( sSQL )
 
' For each row in the query result...
'
Do While ( Not NameDataSet.EOF )
  iTotal = iTotal + 1
 
' Copy the current row into the VB array.
' This looks ugly because it's VB string concatenation  
  VBBSTRArray(iTotal) = iTotal & ") " & NameDataSet("Author") & ".  " & """" & NameDataSet("Title") & """" & ".  " & NameDataSet("Publisher") & ": " & NameDataSet("Year") & ".  " & NameDataSet("ISBN")
  NameDataSet.MoveNext     ' Increment to the next row in query result
 
  if (iTotal >= 1000) Then
    exit do
  end if
 
loop
 
' Close and clear the database connection.
myConnection.Close
Set myConnection = Nothing
 
'Set the VB Array data to the Scala Array
sQueryResult.Value  = VBBSTRArray
[+][-]07.16.2008 at 11:09AM PDT, ID: 22018566

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 02:29PM PDT, ID: 22020381

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Script, MySQL Server
Tags: VBScript
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.16.2008 at 11:38PM PDT, ID: 22022806

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 11:41PM PDT, ID: 22022821

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 14-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.16.2008 at 11:48PM PDT, ID: 22022845

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 11:55PM PDT, ID: 22022873

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 11:56PM PDT, ID: 22022875

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 12:02AM PDT, ID: 22022901

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 14-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.17.2008 at 12:12AM PDT, ID: 22022965

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 12:14AM PDT, ID: 22022975

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 12:14AM PDT, ID: 22022976

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628