|
-
Jun 15th, 2007, 01:59 AM
#1
Thread Starter
Fanatic Member
help with return
hi guys! Can you help me figure out what's wrong with my code below. Thanks in advance!
Code:
public int DAA_AddUserAccount(string user_Name, string user_Password,
string user_Firsname, string user_Lastname,
string user_MiddleInitial)
{
try
{
int returnval = 0;
spName = "sp_User_AddUserAccount";
DBConnection.DBConnection dbConnection = new DBConnection.DBConnection();
connection = dbConnection.CreateConnection();
connection.Open();
command = new SqlCommand();
command.CommandText = spName;
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@User_LogIn", user_Name);
command.Parameters.AddWithValue("@User_PassWord", user_Password);
command.Parameters.AddWithValue("@User_FirstName", user_Firsname);
command.Parameters.AddWithValue("@User_LastName", user_Lastname);
command.Parameters.AddWithValue("@User_MiddleInitial", user_MiddleInitial);
//SqlParameter parameter = command.Parameters.Add("@identity", SqlDbType.Int);
//parameter.Direction = ParameterDirection.Output;
command.Connection = connection;
returnval = command.ExecuteNonQuery();
return returnval;
}
catch (SqlException ex)
{
CommonFunctions.ShowSqlException(ex);
}
finally
{
connection.Close();
}
}
Error 1 'RCPSProject.DAA_Classes.DAA_UserAccount.DAA_AddUserAccount(string, string, string, string, string)': not all code paths return a val
-
Jun 15th, 2007, 02:10 AM
#2
Re: help with return
If an exception is thrown execution will never reach a return statement. You should declare returnval before the try block and place your return statement after the finally block.
-
Jun 15th, 2007, 02:17 AM
#3
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|