Click here to Skip to main content
15,877,376 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello sir


I have create the web application but when login from
web site it give me error.

I have use the Stored procedure at login page. Data base is Sql server 2005

This work fine on my local machine or local server(intranet server). but for live server it not work.

My Sp
==
SQL
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER proc [dbo].[Usp_CheckLogin]
(
    @UserName varchar(150)=NULL
    ,@Password varchar(150)=NULL
    ,@UserIP    VARCHAR(50) = NULL
    ,@ByKit     BIT = 0 
    ,@LoginBy   BIT = 0 
)
as
begin

    DECLARE @UserId INT

    Declare @RowCnt int
    set @RowCnt=0
    select @RowCnt=Count(*) from dbo.User_Mst where UserName=@UserName and Password=@Password
    if (@RowCnt=0)
        Begin
            Select 0 as returnvalue
        End
    Else
    Begin
        Select
            1 as returnvalue,
            UserID,
            UserName,
            UserRole,
            FirstName + '' + LastName [Name],
            FirstName,
            [User].OrganizationId,
            fk_OrganizationTypeId,
            [User].fk_RoleId,
            VideoRecording,
            ContinueActivity
        from dbo.User_Mst [User]
            LEFT JOIN Organization [Org]
                ON [User].OrganizationId = [Org].pk_OrganizationId
        where UserName=@UserName
       
        SELECT @UserId = UserID FROM dbo.User_Mst [User] WHERE UserName=@UserName
        INSERT INTO [LoginHistory_Mst]
        (
            [fk_UserId]
            ,[UserIP]
            ,[LogOutTime]
            ,[ByKit]
            ,[LoginBy]
        )
        VALUES
        (
            @UserId
            ,@UserIP
            ,NULL
            ,@ByKit
            ,@LoginBy
        )
           End
end

==
some time it work or some time it give me error for fi
=========
Column 'Username' does not belong to table Table.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Column 'Username' does not belong to table Table.

Source Error:


Line 109:            End If
Line 110:        Catch ex As Exception
Line 111:            Throw ex
Line 112:        Finally
Line 113:            If IsNothing(dsUser) = False Then



Source File: H:\Inetpub\wwwroot\MRESC_StaticDemo_new\login.aspx.vb Line: 111

Stack Trace:


[ArgumentException: Column 'Username' does not belong to table Table.]
   login.ibtnLogin_Click(Object sender, ImageClickEventArgs e) in H:\Inetpub\wwwroot\MRESC_StaticDemo_new\login.aspx.vb:111
   System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +98
   System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +161
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
Posted
Updated 27-Sep-10 22:43pm
v5

Column 'Username' does not belong to table Table.
Looks like you have given 'Table' as a name to your users table. :doh:
Why do you have to use a sql keyword for naming a table?

If renaming the table does not help then do update your question with stored procedure.
 
Share this answer
 
Well its not your SP error at all.

See you are counting rows using select @RowCnt=Count(*) from dbo.User_Mst... and then if there are no rows you just returning a row
Select 0 as returnvalue
. In your else portion you are returning a row of
SQL
Select 1 as returnvalue, UserID, UserName,...
. So you can clearly see that in two cases the returned datatable will be different. I guess you are trying to get the value of UserName field after execution of the SP. Debug the code and you get your ans.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900