Avatar of Michael Katz
Michael KatzFlag for United States of America

asked on 

Using a VB SCript to call Sql View with Parameter

I have a view..VWOpenOrders...

.SELECT     SUM(SorDetail.MOrderQty * SorDetail.MPrice) AS Line, ArCustomer.Name
FROM         SorMaster INNER JOIN
                      ArCustomer ON SorMaster.Customer = ArCustomer.Customer LEFT OUTER JOIN
                      SorDetail ON SorMaster.SalesOrder = SorDetail.SalesOrder
WHERE     (SorMaster.OrderStatus <> '9')
GROUP BY  ArCustomer.Name...

and the Corresponding VB Script is

dim objConnection, objRecordSet

Set objConnection = CreateObject("ADODB.Connection")

Set objRecordSet = CreateObject("ADODB.Recordset")
 

objConnection.Open = "Provider=SQLOLEDB;Data Source=VMXP-SYSSQL08;Initial Catalog=SysproOutdoors;User ID=sa;pwd=100399"

objRecordSet.Open "select Name,Line from VWOpenOrders", objConnection, adOpenStatic, adLockOptimistic


How can i have a parameter field based on entry for ArCustomer.Name
VB ScriptMicrosoft SQL Server 2008

Avatar of undefined
Last Comment
Metehan Ozcullu
Avatar of Metehan Ozcullu
Metehan Ozcullu
Flag of Türkiye image

dim objConnection, objRecordSet, tparameter

Set objConnection = CreateObject("ADODB.Connection")

Set objRecordSet = CreateObject("ADODB.Recordset")

tparameter=""

objConnection.Open = "Provider=SQLOLEDB;Data Source=VMXP-SYSSQL08;Initial Catalog=SysproOutdoors;User ID=sa;pwd=100399"

objRecordSet.Open "select Name,Line from VWOpenOrders", objConnection, adOpenStatic, adLockOptimistic

objRecordSet.Open "select Name,Line from VWOpenOrders where ArCustomer.Name='"&tparameter&"', objConnection, adOpenStatic, adLockOptimistic
Avatar of Metehan Ozcullu
Metehan Ozcullu
Flag of Türkiye image

last line should be

objRecordSet.Open "select Name,Line from VWOpenOrders where ArCustomer.Name='"&tparameter&"'", objConnection, adOpenStatic, adLockOptimistic
Avatar of Michael Katz
Michael Katz
Flag of United States of America image

ASKER

I am getting an error that says  'Operaion is not allowed when the object is open'

Any thoughts??
ASKER CERTIFIED SOLUTION
Avatar of Metehan Ozcullu
Metehan Ozcullu
Flag of Türkiye image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Microsoft SQL Server 2008
Microsoft SQL Server 2008

Microsoft SQL Server 2008 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. Major improvements include the Always On technologies and support for unstructured data types.

50K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo