Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i m getting error as scalar variable must be at email

C#
public DataSet logindetailsDAl()
        {
            try
            {

                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConsString"].ConnectionString);
                con.Open();
                SqlCommand cmd = new SqlCommand(" SELECT * FROM resource WHERE Email=@Email, Password=@Password and OrganisationID=@OrganisationID", con);
                
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
Posted
Updated 29-Jan-13 0:54am
v3

Hi Angelina,

You forgot to enter the values of the parameters in the SQL Command!

C#
cmd.Parameters.Add("@Email", MyMailAddress); // add value of the parameters to the command 


Cheers,
Edo
 
Share this answer
 
v2
Comments
fjdiewornncalwe 30-Jan-13 9:49am    
My 5. This is the correct way to do this.
Are you from SQL background ?

SQL
CREATE PROCEDURE CheckAuthantication(@UserId NVARCHAR(50) , @Password NVARCHAR(50))
BEGIN
DECLARE @IsAuthanicated NVARCHAR(5)
SET  @IsAuthanicated='0'
SELECT  @IsAuthanicated=1 FROM Users WHERE Userid=@Userid AND Password=@Password
IF  @IsAuthanicated='0' THEN
 SET @IsAuthanicated='False'
ELSE
 SET  @IsAuthanicated='True'
END IF
END


Now run this procedure on sql server and call this from your code and check for value if 'True' then authenticate user otherwise not

Accept and vote if helps otherwise revert back with queries
--RDB
 
Share this answer
 
v2
Comments
Dhritirao's 29-Jan-13 6:27am    
Must declare the scalar variable "@Email". i m getting this error
RDBurmon 29-Jan-13 6:37am    
I have updated my solution please see

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