CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.microsoft_application_blocks Tags:
Item Type: NewsGroup Date Entered: 11/6/2003 6:05:44 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 4 Views: 239 Favorited: 0 Favorite
5 Items, 1 Pages 1 |< << Go >> >|
ZackJones
Asp.Net User
ExecuteScalar Always Returns 011/6/2003 6:05:44 PM

0

Greetings,

I'm trying to convert an application over to the Data Access application block and I'm getting stuck :(

Below is the code I'm trying to use. Everything worked properly before I started to convert it over. Any pointers would be greatly appreciated


Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
If Page.IsValid Then
Try
'Dim Conn As New SqlConnection(ConfigurationSettings.AppSettings("connStr"))
'Dim cmd As New SqlCommand("CheckLogin", Conn)
'cmd.CommandType = CommandType.StoredProcedure
Dim Param(1) As SqlParameter
Dim strCryptPass As String
Dim intResult As Integer
Param(0) = New SqlParameter("@username", SqlDbType.VarChar)
Param(0).Value = Replace(txtUsername.Text, "'", "''")
'cmd.Parameters.Add(Param)
strCryptPass = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.ToLower, "sha1")
Param(1) = New SqlParameter("@password", SqlDbType.VarChar)
Param(1).Value = strCryptPass
'cmd.Parameters.Add(Param)
'Conn.Open()
'cmd.ExecuteNonQuery()
'intResult = cmd.Parameters("@RETURN_VALUE").Value
'Conn.Close()
intResult = Convert.ToInt32(SqlHelper.ExecuteScalar(ConfigurationSettings.AppSettings("connStr"), CommandType.StoredProcedure, "CheckLogin", Param))

Select Case intResult
Case Is > 0
CreateTicket(txtUsername.Text, intResult)
Case -1
lblErr.Text = "Username could not be found"
Case -2
lblErr.Text = "Passwords do not match"
End Select
Catch ex As Exception
lblErr.Text = ex.Message
End Try
End If
End Sub



LesioS
Asp.Net User
Re: ExecuteScalar Always Returns 011/17/2003 7:43:45 AM

0

How "CheckLogin" sp looks like?

I've method

public int CheckLogin(string userName, string passPhrase)
{
object o = SqlHelper.ExecuteScalar(_connString, "CheckLogin", userName, passPhrase);
return o == null ? -1 : (int)o;
}

and associated sp:

ALTER PROCEDURE dbo.CheckLogin
(
@UserName nvarchar(50),
@Password nvarchar(50)
)
AS
SELECT UserId
FROM Users
WHERE (Password = @Password) AND (Activated = 1) AND (NickName = @UserName)
RETURN

It works fine.
Best regards,
LesioS
ZackJones
Asp.Net User
Re: ExecuteScalar Always Returns 011/18/2003 12:00:35 PM

0

Here's my CheckLogin SP:


CREATE PROCEDURE [dbo].[CheckLogin]
@username varchar(50),
@password varchar(50)
AS
declare @id int
declare @actualpassword varchar(50)
select @id = accesslevel,
@actualpassword = password
from users
where username = @username

If @id is not null
if @password = @actualpassword
return @id
else
return -2
else
return -1
GO


Thanks for taking the time to reply :)
scampbell12001
Asp.Net User
Re: ExecuteScalar Always Returns 012/1/2003 10:50:02 PM

0

It looks like you are using a "Return" statement to send the scaler value back, you need to have a select which returns a single value.
ZackJones
Asp.Net User
Re: ExecuteScalar Always Returns 012/2/2003 11:18:47 AM

0

That makes sense now that you mention it, thanks for clearing this one up for me :)

Zack
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Building distributed applications with Visual Basic.NET Authors: Dan L. Fox, Quilogy, Inc, Pages: 763, Published: 2002
Microsoft Visual Basic .NET 2003 kick start Authors: Duncan Mackenzie, Andy Baron, Erik Porter, Joel Semeniuk, Pages: 320, Published: 2003
Beginning C# databases: from novice to professional Authors: James Huddleston, Ranga Raghuram, Scott Allen, Syed Fahad Gilani, Jacob Hammer Pedersen, Jon Reid, Pages: 622, Published: 2004
Beginning VB 2008 Databases: From Novice to Professional Authors: Vidya Vrat Agarwal, James Huddleston, Pages: 409, Published: 2008
Special edition using Visual Basic.NET Authors: Brian Siler, Jeff Spotts, Pages: 830, Published: 2001

Web:
always getting a 0 returned using ExecuteScalar (ms datablocks) always getting a 0 returned using ExecuteScalar (ms datablocks). Anyone know why I'm always getting 0 returned? My stored procedure returns ...
How to detect NULL value with cmd.ExecuteScalar(); I have tried the below code, however, it always returns false (this is to say, that ExecuteScalar never returns NULL when in fact it does): ...
ExecuteScalar Always Returns 0 - ASP.NET Forums Greetings, I'm trying to convert an application over to the Data Access application block and I'm getting stuck :( ...
ExecuteScalar returns 0 (null) but INSERT is successful. Sep 25, 2007 ... ExecuteScalar returns 0 (null) but INSERT is successful. ... but the scope_identity always have the value whichever your current scope ...
ExecuteScalar returns null - bytes When my application runs, the ExecuteScalar returns "10/24/2006 2:00:00 PM" ... questions in this newsgroup before posting yours - always a ...

ExecuteScalar Always Returns 0 - ng.asp-net-forum ... ExecuteScalar Always Returns 0, > ROOT > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.microsoft_application_blocks, ...
MS DAAB For Oracle - ExecuteScalar with Stored Procedure - ng.asp ... Either don't use stored procs when using ExecuteScalar, or you'll have to go with .... ExecuteScalar Always Returns 0 - ng.asp-net-forum . ...
System.InvalidCastException to ArrayList? - ng.asp-net-forum ... You want to return a printerID but transfer this into an IDataReader. ... ExecuteScalar Always Returns 0 - ng.asp-net-forum ... System. ...
SqlHelper.ExecuteReader not populating ReturnValue - ng.asp-net ... I have StoredProc,which returns 0 if there is no error. .... MS DAAB For Oracle - ExecuteScalar with Stored Procedure - ng.asp . ...
cant insert into DB - data_access ... Additionally, ExecuteScalar returns the first column of the first row of the ... is a small C library that implements a self-contained, embeddable, zero . ...






closing connection

documentation

data access and three tier

cryptography application block - key not valid for use in specified state

datareader leaking connections.

data retrieval using dataset in vb.net

getting errors out of data access block

am i missing something about application blocks?

is there any way i can make a outlook 2003 task list and calendar like ui control?

email sink

the located assembly's manifest definition does not match the assembly reference.

clean cached parameters

no results available for the request id

user interface process application block in .net 2.0?

inserting data using stored procs with daab (enterprise library 2.0)

oracle dataaccess -- executedataset wrong?

how to use ref cursor to retrieve dataset from oracle using microsoft data application block?

system.configuration.configurationexception

how to use exception and log application block to log errors and exception in database in asp.net application

has anyone used this block visual studio 2005 beta?

daab 3.1 to access oracle

urgent help:applicationblocks

asp.net and registry...

addoutparameter for guid?

uip 2.0 & asp.net 2.0... does it work?

need help with the daab and multiple databases.

webformview event question, why?

problems running sample

example on sqlhelper.updatadataset

configuration error in uiprocess application block version 1.0.0.1

   
  Privacy | Contact Us
All Times Are GMT