Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBSCRIPT to call SQL Stored Procedure in Outlook form

Status
Not open for further replies.

csudougie

MIS
Dec 15, 2006
37
0
0
Hello,

I'm having trouble getting my vbscript to execute a SQL stored procedure over an ODBC connection from an Outlook form.

The s.p. only accepts one integer and returns a string value. Can anyone help me with the syntax or point me in a direction. I've looked into pass-through queries, but they want to run in VB and the funtions I've found don't like vbscript.

Thanks.

Option Explicit
dim rc, sql, cnn

sub OpenConn()
dim dsn
set cnn = CreateObject("ADODB.Connection")
dsn = "Provider=sqloledb;Data Source=MAJ_LINKED_TABLES;"
cnn.Open dsn
SQL = "{EXECUTE dbo.GET_CUS_NAME_fn(myvalue)}"
end sub

Sub cmdTest_Click()

dim objPage, objControl
dim s
dim MyValue
Set objPage = Item.GetInspector.ModifiedFormPages("Message")
Set objControl = objPage.Controls("txt_So")
MyValue = objControl.Value
OpenConn()
rc = cnn.Execute (SQL)
msgbox rc
end sub
 
I'd use a Command object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top