VoiceGuide IVR Software Main Page
Jump to content

Mysql Vbs Connection

Recommended Posts

Hello everyone,

 

I have read your instructions to use VBS instead of the "query database" function to send info to a mySQL database, but I have no clue how to connect to the database using VBS. Im a PHP programmer. I cannot find help that I can decipher on any other board. Can someone write a connection example as simply as possible so I can understand how it works. I keep getting crazy errors like "unexpected end of statement" from the windows compiler.

 

All I want to do is get a any query to work, I can take it from there.

 

sql = "SELECT * FROM outbound";

 

 

Thank you for your help.

Share this post


Link to post

Please .ZIP up and post your VoiceGuide script from within which you are trying to connect to MySQL from, and indicate which module in the script is doing the connection.

Share this post


Link to post

here is a code fragment I have used to connect to a mysql database which works fine. The driver specified is available from www.mysql.com and must be installed for this to work.

 

'Create VC command link object

Set constvg = Nothing

Set conn = CreateObject("ADODB.Connection")

conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _

& "SERVER=" + url + ";" _

& "DATABASE=" + database + ";" _

& "UID=" + username + ";" _

& "PWD=" + password + ";" _

& "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384

conn.Open

 

'Set userPin equals to user entered number

usrPin = "$RV_ENTEREDNUMBER"

iLen = Len("$RV_ENTEREDNUMBER")

userID = checkValidPin(usrPin)

If userID = "true" Then

userID = getUserID (usrPin)

End If

If userID = "false" Then

sResult = FAIL

wavePath = BAD_PIN

vg.RvSet $RV_LINEID, "WavePath", wavePath

vg.Run_ResultReturn $RV_LINEID, sResult

Set vg = Nothing

Else

Validated ()

End If

 

 

 

conn.Close

Set conn = Nothing

Share this post


Link to post

here is the example function that connects to the db

 

Function getUserID (userPin)

Dim userID

query = "Select userid from authoriseduser a, contact c " &_

"where a.userid=c.contactid " &_

"And c.status='Active' " &_

"And a.pin=" & usrPin

 

Set rs = conn.Execute (query)

If (rs.BOF = True) Then

vg.RvSet $RV_LINEID, "PinError", "BadPin"

userID = "false"

Else

userID = rs("userID")

vg.RvSet $RV_LINEID, "DefaultMSGLoc", DEFAULT_MSG

vg.RvSet $RV_LINEID, "UserID", userID

End If

Call closeRS (rs)

 

getUserID = userID

 

End Function

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×