I am trying to pass an input parater to SQL Server. The parameter is a URL
querystring variable. I can't seem to get it to pass a variable, only a
literal value...
Help!
In the following example, the @archiveType parameter accepts the "all"
sample value. If I replace "all" with Request.QuerySt ring("archiveTy pe"),
it doesn't work. What am I doing wrong?
'SqlSelectComma nd1
'
Me.SqlSelectCom mand1.CommandTe xt = "[myProcedure]"
Me.SqlSelectCom mand1.CommandTy pe = System.Data.Com mandType.Stored Procedure
Me.SqlSelectCom mand1.Connectio n = Me.SqlConnectio n1
Me.SqlSelectCom mand1.Parameter s.Add(New
System.Data.Sql Client.SqlParam eter("@RETURN_V ALUE",
System.Data.Sql DbType.Int, 4, System.Data.Par ameterDirection .ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.Dat aRowVersion.Cur rent, Nothing))
Me.SqlSelectCom mand1.Parameter s.Add(New
System.Data.Sql Client.SqlParam eter("@archiveT ype",
System.Data.Sql DbType.VarChar, 5, System.Data.Par ameterDirection .Input,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.Dat aRowVersion.Cur rent, "all"))
---------------------------------
Here's the procedure:
CREATE PROCEDURE myProcedure
@archiveType varchar(5)
as
SELECT col1
FROM table1
WHERE col1 = @archiveType
--
_____
DC G 1 1498
When you refer to a variable like this you need to get the compiler to
recognize it.
If ArchiveType is declared as a string, this should work. If it's a TextBox
control you'll need to refer to the Text property. I'll be discussing these
issues in my workshop in Orlando this weekend and in my session in Chicago
in late October. I'm also doing sessions in Las Vegas in early November.
With Me.SqlSelectCom mand1
.CommandText = "[myProcedure]"
.Connection = Me.SqlConnectio n1
.Parameters.Add ("@RETURN_VALUE ").Direction=Sy stem.Data.Param eterDirection.R eturnValue
.Parameters.Add ("@archiveType" ,System.Data.Sq lDbType.VarChar , 5).Value =
ArchiveType
End With
hth
--
_______________ _______________ ______
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
_______________ _______________ ____
"DC Gringo" <dc******@visio ntechnology.net > wrote in message
news:uL******** ******@TK2MSFTN GP14.phx.gbl... I am trying to pass an input parater to SQL Server. The parameter is a URL querystring variable. I can't seem to get it to pass a variable, only a literal value...
Help!
In the following example, the @archiveType parameter accepts the "all" sample value. If I replace "all" with Request.QuerySt ring("archiveTy pe"), it doesn't work. What am I doing wrong?
'SqlSelectComma nd1 ' Me.SqlSelectCom mand1.CommandTe xt = "[myProcedure]" Me.SqlSelectCom mand1.CommandTy pe = System.Data.Com mandType.Stored Procedure Me.SqlSelectCom mand1.Connectio n = Me.SqlConnectio n1 Me.SqlSelectCom mand1.Parameter s.Add(New System.Data.Sql Client.SqlParam eter("@RETURN_V ALUE", System.Data.Sql DbType.Int, 4, System.Data.Par ameterDirection .ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.Dat aRowVersion.Cur rent, Nothing)) Me.SqlSelectCom mand1.Parameter s.Add(New System.Data.Sql Client.SqlParam eter("@archiveT ype", System.Data.Sql DbType.VarChar, 5, System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte), "", System.Data.Dat aRowVersion.Cur rent, "all"))
---------------------------------
Here's the procedure:
CREATE PROCEDURE myProcedure
@archiveType varchar(5)
as
SELECT col1 FROM table1 WHERE col1 = @archiveType
-- _____ DC G This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John T |
last post by:
I am trying to make a function that takes an optional parameter that gets
passed by reference.
Here is the first line of my function definition:
function funQueryDatabase($strQuery, &$intInsertId = NULL) {
I am getting this error:
Parse error: parse error, expecting `')'' in c:\program
|
by: JIMMIE WHITAKER |
last post by:
The below stored procedure works. However, I am trying to use a text box
from a temp form for the where clause.
WHERE Transactions.TransactionID = !!
I even tried changing first line:
Alter PROCEDURE S3 @TID varchar (255) = !!
And changed last line to:
WHERE Transactions.TransactionID = @TID
So far, I haven't been able to have this parameter work from a temp form
with the parameter typed into the text0 box.
any help here? I get ado...
|
by: SB |
last post by:
Ok, very simple problem. I'm trying to update a value by calling a function
using pass by reference, but it does not update the value. In short, the
value I'm trying to update is balance, which is a private member of the
class Account. I have a public function called getBalance(). I have another
public function called deposit, which I pass the balance (by calling
getBalance() using pass by reference) and a second value for the amount of...
|
by: Don |
last post by:
I have a third party C++ DLL that I am trying to use from C#. The
specific function I am trying to use is declared in C++ as follows:
ladybugConvertToMultipleBGRU32(
LadybugContext context,
const LadybugImage* pimage,
unsigned char* arpszDestBuffers,
LadybugImageInfo* pImageInfo );
|
by: intrepid_dw |
last post by:
Hello, all.
I've created a C# dll that contains, among other things, two functions
dealing with byte arrays. The first is a function that returns a byte
array, and the other is intended to receive a byte array as one of its
parameters. The project is marked for COM interop, and that all
proceeds normally.
When I reference the type library in the VB6 project, and write the
code to call the function that returns the byte array, it works
| |
by: Darth Ferret |
last post by:
On the last statement below, I am getting this error -
'System.InvalidCastException'
Does anyone know what is causing this? I am trying to pass a parameter to a
stored procedure in an iseries. My connection opens and I can call a stored
procedure with no parameters. The problem is that I cannot pass any
parameters.
'create command object
|
by: =?Utf-8?B?UHVjY2E=?= |
last post by:
The function that I'm trying to call through DLLImport has a parameter that
has a C code's vector's Itrator to a structure. I Have marshalled the
structure in C# but how do I do the C type vector's Iterator in C#? The
problem is in the next line and the rest of the code is just additional
information on what I'm doing. Thanks.
CUnityDS.DE_ERRORS errcode = CUnityDS.LibWrap.EncodeAsnUser(ref blob,
userContextData);
//In & out...
|
by: Kourosh |
last post by:
Hi all,
I'm trying to call a COM function from C#
The function gets a paramter of type IStream in C++. I've found the
type System.Runtime.InteropServices.ComTypes.IStream, however I'm not
sure how to create an instance of it to pass as the parameter. Anyone
can tell me what to do? i dont know what to pass in as the parameter,
because I'm not sure how to create an instance of the "IStream" object
in C#
|
by: vijaykumardahiya |
last post by:
Hello Sir,
I have a simple Issue but It is not resolve by me i.e input parameter
are not store in Ms-Access.
I store the input parameter through Standard Action <jsp:useBean>.
jsp:useBean call a property IssueData. this property exist in
SimpleBean which create a connection from DB and insert the data.
At run time servlet and server also show that loggging are saved in DB.
But when I open the table in Access. Its empty.
Ms-Access have...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |