Re: Passing Data with Hidden Fields asp.net

From: Patrick Olurotimi Ige (ige_at_iprimus.com.au)
Date: 01/27/05


Date: Wed, 26 Jan 2005 23:17:57 -0800

Ken for the sample but i have another Questions below:-
--------------------------------------------------------
When u click on the SURVEY link it checks if the USER is in the Database
if he/she is in the DB it retunrs access denied Which i have done.
And if they aren't INSERT the user..

But getting problems with my stored procedure below:-

CREATE procedure oyinbo(@username varchar(50), @password varchar(50) )
as
if exists
-- You cannot register usernames already registered on the database
twice.
(
select username from register where username = @username
)
return 1 else
insert register(username,password) values(@username,@password)
GO

It checks the USER and denies it but it never gives me access to the
page ...which i think it inserts the user before checking..

My codebehind is :-
 Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

        conn = New
SqlConnection("server=(local);database=mydatabase;integrated
security=true;")
        conn.Open()
        txtuser.ID = Request.ServerVariables("LOGON_USER")

          cmdcommand = New SqlCommand("rote", conn)
        cmdcommand.CommandType = CommandType.StoredProcedure
        param = cmdcommand.Parameters.Add("ReturnValue", SqlDbType.Int)
        param.Direction = ParameterDirection.ReturnValue
        cmdcommand.Parameters.Add("@username", txtuser.Name)

        'cmdcommand.Parameters.Add(New SqlParameter("@DateCreated",
SqlDbType.DateTime, 8))
        'cmdcommand.Parameters("@DateCreated").Value = Now()

        cmdcommand.ExecuteNonQuery()

        If cmdcommand.Parameters("ReturnValue").Value = 1 Then

          Response.redirect("noaccess.aspx")
          ' lblMessage.Text = "Username already exists!"
        Else

           ' lblMessage.Text = "Success!"
        Response.Redirect("startsurvey.aspx")

       End If

     conn.Close()

    End Sub

Anything i'm doing wrong?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!