Advertisement
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.
Your Input Matters 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! |
||
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
|