Error trying to call stored procedure with prepared statement

You want something like this (untested) Dim cmd, rs, ars, conn Set cmd = Server.CreateObject(“ADODB.Command”) With cmd ‘Assuming passing connection string if passing ADODB.Connection object ‘make sure you use Set .ActiveConnection = conn also conn.Open should ‘have been already called. .ActiveConnection = conn ‘adCmdStoredProc is Constant value for 4 (include adovbs or ‘set typelib in … Read more

How to use Alias in Where clause? [duplicate]

You can’t reference the column alias in the WHERE clause – your options are: replicate the CASE statement in the WHERE clause use a subquery: PROCEDURE P_LOAD_EXPIRED_ACCOUNT(pDayDiff NUMBER, ExpiredCur OUT MEGAGREEN_CUR) IS BEGIN OPEN ExpiredCur FOR SELECT x.account_name, x.service_type, x.expired_date FROM (SELECT s.account_name, s.service_type, CASE WHEN s.service_type = 1 THEN ADD_MONTHS(ACTIVATED_DATE,3) WHEN s.service_type = 2 … Read more

Execute a SQL Stored Procedure and process the results [closed]

At the top of your .vb file: Imports System.data.sqlclient Within your code: ‘Setup SQL Command Dim CMD as new sqlCommand(“StoredProcedureName”) CMD.parameters(“@Parameter1”, sqlDBType.Int).value = Param_1_value Dim connection As New SqlConnection(connectionString) CMD.Connection = connection CMD.CommandType = CommandType.StoredProcedure Dim adapter As New SqlDataAdapter(CMD) adapter.SelectCommand.CommandTimeout = 300 ‘Fill the dataset Dim DS as DataSet adapter.Fill(ds) connection.Close() ‘Now, read through … Read more

Converting String List into Int List in SQL

It is possible to send an int list to your stored procedure using XML parameters. This way you don’t have to tackle this problem anymore and it is a better and more clean solution. have a look at this question: Passing an array of parameters to a stored procedure or check this code project: http://www.codeproject.com/Articles/20847/Passing-Arrays-in-SQL-Parameters-using-XML-Data-Ty … Read more