Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually I’m working on an Asp.Net three-tier architecture project. When I try to
write code for the data access layer I’m getting the error below. Please help. (email removed)

public int insertlogin(DataContainer objdc,string CmdText)
{
    Util.Open();
    SqlCommand Cmd = new SqlCommand();
    Cmd.Parameters.Clear();
    Cmd.Connection = Util.SqlCon;
    Cmd.CommandType = CommandType.StoredProcedure;
    Cmd.CommandText = CmdText;
    Cmd.Parameters.Add("@id", SqlDbType.Int).Value = objdc.id;
    Cmd.Parameters.Add("@username", SqlDbType.VarChar, 50).Value = objdc.username;
    Cmd.Parameters.Add("@password", SqlDbType.VarChar, 50).Value = objdc.password;
    Cmd.ExecuteNonQuery();
    Util.Close();
}
Posted
Updated 1-Jul-11 3:30am
v3
Comments
R. Giskard Reventlov 1-Jul-11 9:31am    
So what's the error?
Nagasreenu Pasupuleti 1-Jul-11 10:00am    
Error: not all code paths return a value
#realJSOP 1-Jul-11 9:36am    
You gave us your code, but not the error.
Nagasreenu Pasupuleti 1-Jul-11 10:01am    
Error:not all code paths return a value

You haven't returned anything from the routine (needs to return an int value)

public int insertlogin(DataContainer objdc,string CmdText)
{
    Util.Open();
    SqlCommand Cmd = new SqlCommand();
    Cmd.Parameters.Clear();
    Cmd.Connection = Util.SqlCon;
    Cmd.CommandType = CommandType.StoredProcedure;
    Cmd.CommandText = CmdText;
    Cmd.Parameters.Add("@id", SqlDbType.Int).Value = objdc.id;
    Cmd.Parameters.Add("@username", SqlDbType.VarChar, 50).Value = objdc.username;
    Cmd.Parameters.Add("@password", SqlDbType.VarChar, 50).Value = objdc.password;
    Cmd.ExecuteNonQuery();
    Util.Close();


    int loginReturnValue = 0; // Populate whatever the return value should be? 
    return loginReturnValue;
}
 
Share this answer
 
Comments
Uday P.Singh 1-Jul-11 11:20am    
good answer my 5 :)
Nagasreenu Pasupuleti 1-Jul-11 13:42pm    
thank you for giving solution actually i want one sample three tier architecture for my loginpage me trying but not getting.Pls if u dont have any sample, pls help me out how to write code in three tier architecture.
Christian Graus 2-Jul-11 2:45am    
Quite honestly if you could not work out what the error meant, or that your method returns an int, a 3 tiered project is certainly beyond you. Choose something easier to learn from for now.
Here i post the link download the sample project of the three tier architecture....
3-tier architecture in C#[^]

Best OF Luck.....
 
Share this answer
 
refer this for 3-tier:

http://www.dotnetfunda.com/articles/article71.aspx[^]

hope this helps :)
 
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