I've got a stored procedure which works as expected using Run Stored
Procedure in VS.NET:-
-----------------------------------------------------------
ALTER PROCEDURE dbo.ValidateUse r
@Username nVarChar(50),
@Password nVarChar(24),
@Valid nvarchar(36) OUTPUT
as
Select @Valid=cast(Use rID as nvarchar(36)) From userdata
Where Username=@Usern ame
and Password=@Passw ord
-----------------------------------------------------------
UserID is a uniqueIdentifie r.
But I can't get a value from @Valid in VB.NET using an output paramater,
it's always an empty string:-
-----------------------------------------------------------
Private sqlConnectionSt ring As String =
ConfigurationSe ttings.AppSetti ngs("sqlConnect ionString")
Public Function validateUser(By Val nam As String, ByVal pwd As String) As
String
Dim sqlCmd As New SqlCommand("val idateUser", sqlConn)
sqlCmd.CommandT ype = CommandType.Sto redProcedure
Dim sqlParam As New SqlParameter("@ UserName", SqlDbType.NVarC har)
sqlParam.Value = Trim(nam)
sqlCmd.Paramete rs.Add(sqlParam )
sqlParam = New SqlParameter("@ Password", SqlDbType.NVarC har)
sqlParam.Value = Trim(pwd)
sqlCmd.Paramete rs.Add(sqlParam )
Dim sqlParamUserID As New SqlParameter("@ Valid", SqlDbType.NVarC har)
sqlParamUserID. Value = ""
sqlParamUserID. Direction = ParameterDirect ion.Output
sqlCmd.Paramete rs.Add(sqlParam UserID)
Try
If sqlConn.State <> ConnectionState .Open Then
sqlConn.Open()
End If
sqlCmd.ExecuteR eader()
Catch e As Exception
Throw e
End Try
sqlConn.Close()
Return CType(sqlParamU serID.Value, String)
End Function
-----------------------------------------------------------
However, if I change the stored procedure to return an int (e.g. select
@Valid=count(*) ), and change the VB to expect a number then it does work.
What am I doing wrong?
Andrew 1 1352
Andrew Morton wrote: ALTER PROCEDURE dbo.ValidateUse r @Username nVarChar(50),
<snip>
Dim sqlParam As New SqlParameter("@ UserName", SqlDbType.NVarC har)
Solution: use the size parameter, as in
Dim sqlParam As New SqlParameter("@ UserName", SqlDbType.NVarC har, 50)
Andrew This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Shapper |
last post by:
Hello,
I have created 3 functions to insert, update and delete an Access
database record. The Insert and the Delete code are working fine.
The update is not. I checked and my database has all the necessary
records in it when testing it. I get the error "No value given for one
or more required parameters." when I try to update the...
|
by: Mart |
last post by:
Hi everybody,
I plan to have a LOT of SQL string in my app. So I need your advice for
this.
Is it a good idea to store all my SQL string in the app.config file?
For a maintenance point of vue it would be easy to access and change any
SQL squery without having to open/edit any forms.
|
by: Greg Schumacher |
last post by:
Running PHP v5.0.4 (compiled by www.entropy.ch) and mysql 5.0.16 on Mac
OS X 10.4.3. When I run the simple test script below the first query
sent from PHP to MySQL is successful but the second is not. sp_select is a
simple one-line script that performs "select * from test". If I replace
the call to the stored procedure with a select that does...
|
by: William |
last post by:
I have the following javascript function that updates a scroll_list and
sends the updated entry (with its index) to a server script
( i.e. http://mkmxg00/cgi/confirmUpload.pl ) for further processing:
function saveText( scroll_list, t_area, listToBeUpdated ) {
scroll_list.options.text = t_area.text;
scroll_list.options.value= t_area.value;...
|
by: Robert |
last post by:
I am trying to give the user dynamic search capabilities to select
almost any record in the database from criteria they select. Everything
seems to work except when I open the display form to display the data
to the user. If that form is already open, how do I make it refresh its
data source and display the new data.
Here is what I am...
| |
by: whulling |
last post by:
I have been coding for a while, and admittedly am a bit of a hack / learn as you go type of person, so I am sure this code is not pretty, any help would be greatly appreciated, I've been stuck for a couple of days on this and have tried all the different ways I know.
The goal of this code is to on click:
1. check to see if a combo box is blank -...
|
by: jwgoerlich |
last post by:
Hello group,
I am working on a query string class. The purpose is to parse
name-value pairs from incoming text. Currently, I am using the Regex
code below. I have two questions.
First, the code below does not work if there is a space in the name.
For example, the text "Initial Catalog=test;" parses to name=Catalog
and value=test.
|
by: etuncer |
last post by:
Hello All,
I have Access 2003, and am trying to build a database for my small
company. I want to be able to create a word document based on the data
entered through a form. the real question is this: can Access create
the document and place it as an OLE object to the relevant table?
Any help is greatly appreciated.
Ricky
|
by: Ken Fine |
last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets
and DataTables should be able to answer fairly easily. The basic question is
how I can efficiently match data from one dataset to data in a second
dataset, using a common key. I will first describe the problem in words and
then I will show my code, which has most of the...
|
by: bilibytes |
last post by:
Hi,
I am having a problem with a concatenated string.
I start my string outside of a for() and then, concatenate the string generated with the loop to it.
the string out of the loop looks like this:
$q = "INSERT INTO (asdf1,asdf2,asdf3) VALUES"
then when i add something like this:
$q .="('".$asdf1."', '".$asdf2."', '".$asdf3."')"
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |