Connecting Tech Pros Worldwide Forums | Help | Site Map

select stored procedure

nicholas
Guest
 
Posts: n/a
#1: Nov 19 '05
I want to check if a userlogin already exists, so this is what i did...but
it is not working and I just can't get it to work. Must be something
stupid, but I don't see it ;-)
(I don't get any error, it just doesn't work)

STORED PROCEDURE:
==================

CREATE PROCEDURE sp_select_userlogin
@userlogin nvarchar
AS
SELECT userlogin FROM tbl_users WHERE userlogin = @userlogin
GO


CODE ON ASPX PAGE on mybutton click :
===============================
'define where the connectionstring is here:
Dim MyConnectionString as String =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim ObjReader as SQLDataReader

'make the connection
Dim MyConnection as New
SQLConnection(MyConnectionString)

Dim ObjCmd as SQLCommand= New
SQLCommand("sp_select_userlogin",MyConnection)
ObjCmd.CommandType = CommandType.StoredProcedure



' Set up parameter for stored procedure
ObjCmd.Parameters.Add(New SqlParameter("@userlogin",
SqlDbType.NVarChar, 50))
ObjCmd.Parameters("@userlogin").Value = userlogin.text


Dim daLogins As New SqlDataAdapter(ObjCmd)
Dim dsLogins As New DataSet()


If dsLogins.Tables.Count = 0 Then
lbl_user_allready_exists.visible = false
Else
lbl_user_allready_exists.visible = true
End If

ObjCmd.Connection.Close()




Patrick Olurotimi Ige
Guest
 
Posts: n/a
#2: Nov 19 '05

re: select stored procedure


HI Nicholas..
Try going through this at:-
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=106
it should help you..
Enjoy
Patrick



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
nicholas
Guest
 
Posts: n/a
#3: Nov 19 '05

re: select stored procedure


in the sp I forgot the (50):

@userlogin nvarchar(50)


"nicholas" <murmurait1@hotmail.com> wrote in message
news:%23hHs%23dR3EHA.1264@TK2MSFTNGP12.phx.gbl...[color=blue]
> I want to check if a userlogin already exists, so this is what i did...but
> it is not working and I just can't get it to work. Must be something
> stupid, but I don't see it ;-)
> (I don't get any error, it just doesn't work)
>
> STORED PROCEDURE:
> ==================
>
> CREATE PROCEDURE sp_select_userlogin
> @userlogin nvarchar
> AS
> SELECT userlogin FROM tbl_users WHERE userlogin = @userlogin
> GO
>
>
> CODE ON ASPX PAGE on mybutton click :
> ===============================
> 'define where the connectionstring is here:
> Dim MyConnectionString as String =
> ConfigurationSettings.AppSettings("ConnectionStrin g")
> Dim ObjReader as SQLDataReader
>
> 'make the connection
> Dim MyConnection as New
> SQLConnection(MyConnectionString)
>
> Dim ObjCmd as SQLCommand= New
> SQLCommand("sp_select_userlogin",MyConnection)
> ObjCmd.CommandType = CommandType.StoredProcedure
>
>
>
> ' Set up parameter for stored procedure
> ObjCmd.Parameters.Add(New SqlParameter("@userlogin",
> SqlDbType.NVarChar, 50))
> ObjCmd.Parameters("@userlogin").Value = userlogin.text
>
>
> Dim daLogins As New SqlDataAdapter(ObjCmd)
> Dim dsLogins As New DataSet()
>
>
> If dsLogins.Tables.Count = 0 Then
> lbl_user_allready_exists.visible = false
> Else
> lbl_user_allready_exists.visible = true
> End If
>
> ObjCmd.Connection.Close()
>
>
>[/color]


bruce barker
Guest
 
Posts: n/a
#4: Nov 19 '05

re: select stored procedure


even if there are no users, the result set meta data is returned, so you
need to test the row count not the table count. (i assume you have code to
actually run the query)

try:

lbl_user_allready_exists.visible = dsLogins.Tables(0).Rows.Count >
0

-- bruce (sqlwork.com)


"nicholas" <murmurait1@hotmail.com> wrote in message
news:%23hHs%23dR3EHA.1264@TK2MSFTNGP12.phx.gbl...
| I want to check if a userlogin already exists, so this is what i did...but
| it is not working and I just can't get it to work. Must be something
| stupid, but I don't see it ;-)
| (I don't get any error, it just doesn't work)
|
| STORED PROCEDURE:
| ==================
|
| CREATE PROCEDURE sp_select_userlogin
| @userlogin nvarchar
| AS
| SELECT userlogin FROM tbl_users WHERE userlogin = @userlogin
| GO
|
|
| CODE ON ASPX PAGE on mybutton click :
| ===============================
| 'define where the connectionstring is here:
| Dim MyConnectionString as String =
| ConfigurationSettings.AppSettings("ConnectionStrin g")
| Dim ObjReader as SQLDataReader
|
| 'make the connection
| Dim MyConnection as New
| SQLConnection(MyConnectionString)
|
| Dim ObjCmd as SQLCommand= New
| SQLCommand("sp_select_userlogin",MyConnection)
| ObjCmd.CommandType = CommandType.StoredProcedure
|
|
|
| ' Set up parameter for stored procedure
| ObjCmd.Parameters.Add(New SqlParameter("@userlogin",
| SqlDbType.NVarChar, 50))
| ObjCmd.Parameters("@userlogin").Value = userlogin.text
|
|
| Dim daLogins As New SqlDataAdapter(ObjCmd)
| Dim dsLogins As New DataSet()
|
|
| If dsLogins.Tables.Count = 0 Then
| lbl_user_allready_exists.visible = false
| Else
| lbl_user_allready_exists.visible = true
| End If
|
| ObjCmd.Connection.Close()
|
|
|


Lowell Heddings
Guest
 
Posts: n/a
#5: Nov 19 '05

re: select stored procedure


nicholas wrote:[color=blue]
> Dim daLogins As New SqlDataAdapter(ObjCmd)
> Dim dsLogins As New DataSet()[/color]


Don't you need to add this line right below that:

daLogins.Fill(dsLogins)

Otherwise you aren't filling the dataset, so any check against the
tables won't work.

Lowell


Closed Thread