Click here to Skip to main content
15,913,685 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionDropDownlist Load Pin
Illegal Operation23-Sep-09 17:42
Illegal Operation23-Sep-09 17:42 
AnswerRe: DropDownlist Load Pin
Steve Echols23-Sep-09 17:50
Steve Echols23-Sep-09 17:50 
GeneralRe: DropDownlist Load Pin
Illegal Operation23-Sep-09 17:55
Illegal Operation23-Sep-09 17:55 
GeneralRe: DropDownlist Load Pin
Illegal Operation23-Sep-09 18:01
Illegal Operation23-Sep-09 18:01 
GeneralRe: DropDownlist Load Pin
Steve Echols23-Sep-09 18:05
Steve Echols23-Sep-09 18:05 
GeneralRe: DropDownlist Load Pin
Steve Echols23-Sep-09 18:04
Steve Echols23-Sep-09 18:04 
QuestionASP.NET with AD Pin
Socheat.Net23-Sep-09 17:02
Socheat.Net23-Sep-09 17:02 
AnswerRe: ASP.NET with AD Pin
Abhijit Jana23-Sep-09 17:15
professionalAbhijit Jana23-Sep-09 17:15 
GeneralRe: ASP.NET with AD Pin
Socheat.Net23-Sep-09 17:53
Socheat.Net23-Sep-09 17:53 
AnswerRe: ASP.NET with AD Pin
Arun Jacob23-Sep-09 18:46
Arun Jacob23-Sep-09 18:46 
QuestionAPS.NET Pin
mamix6523-Sep-09 13:24
mamix6523-Sep-09 13:24 
AnswerRe: APS.NET Pin
Not Active23-Sep-09 13:36
mentorNot Active23-Sep-09 13:36 
GeneralRe: APS.NET Pin
N a v a n e e t h23-Sep-09 15:29
N a v a n e e t h23-Sep-09 15:29 
GeneralRe: APS.NET Pin
Christian Graus23-Sep-09 17:14
protectorChristian Graus23-Sep-09 17:14 
GeneralRe: APS.NET Pin
Not Active24-Sep-09 1:02
mentorNot Active24-Sep-09 1:02 
AnswerRe: APS.NET Pin
Christian Graus23-Sep-09 15:28
protectorChristian Graus23-Sep-09 15:28 
Questiondata access Pin
raquidd2223-Sep-09 11:26
raquidd2223-Sep-09 11:26 
AnswerRe: data access Pin
Abhishek Sur23-Sep-09 12:17
professionalAbhishek Sur23-Sep-09 12:17 
GeneralRe: data access Pin
N a v a n e e t h23-Sep-09 15:47
N a v a n e e t h23-Sep-09 15:47 
GeneralRe: data access Pin
Abhishek Sur23-Sep-09 23:28
professionalAbhishek Sur23-Sep-09 23:28 
GeneralRe: data access Pin
N a v a n e e t h24-Sep-09 5:03
N a v a n e e t h24-Sep-09 5:03 
GeneralRe: data access Pin
Abhishek Sur25-Sep-09 12:16
professionalAbhishek Sur25-Sep-09 12:16 
GeneralRe: data access Pin
raquidd2230-Sep-09 6:27
raquidd2230-Sep-09 6:27 
AnswerRe: data access Pin
N a v a n e e t h23-Sep-09 15:44
N a v a n e e t h23-Sep-09 15:44 
GeneralRe: data access Pin
raquidd2224-Sep-09 6:38
raquidd2224-Sep-09 6:38 
thank for all
thanks N a v a n e e t h


i understand all coment about byval o vbyref, first time i see the out parameter in c#.
the code original is and working, i tested.

public class PersonDataService
           public void Person_Save(ref int personID, string nameFirst, string nameLast, DateTime dob)
        {
            SqlCommand cmd;
            ExecuteNonQuery(out cmd, "Person_Save",
                CreateParameter("@PersonID", SqlDbType.Int, personID, ParameterDirection.InputOutput),
                CreateParameter("@NameFirst", SqlDbType.NVarChar, nameFirst),
                CreateParameter("@NameLast", SqlDbType.NVarChar, nameLast),
                CreateParameter("@DOB", SqlDbType.DateTime, dob));            
            personID = (int)cmd.Parameters["@PersonID"].Value;
            cmd.Dispose();
        }



and the class

        protected void ExecuteNonQuery(string procName,
            params IDataParameter[] procParams)
        {
            SqlCommand cmd;
            ExecuteNonQuery(out cmd, procName, procParams);
        }
protected void ExecuteNonQuery(out SqlCommand cmd, string procName,
            params IDataParameter[] procParams)
        {
            //Method variables
            SqlConnection cnx = null;
            cmd = null;  //Avoids "Use of unassigned variable" compiler error

            try
            {
                //Setup command object
                cmd = new SqlCommand(procName);
                cmd.CommandType = CommandType.StoredProcedure;
                for (int index = 0; index < procParams.Length; index++)
                {
                    cmd.Parameters.Add(procParams[index]);
                }

                //Determine the transaction owner and process accordingly
                if (_isOwner)
                {
                    cnx = new SqlConnection(GetConnectionString());
                    cmd.Connection = cnx;
                    cnx.Open();
                }
                else
                {
                    cmd.Connection = _txn.Connection;
                    cmd.Transaction = _txn;
                }

                //Execute the command
                cmd.ExecuteNonQuery();
            }
            catch
            {
                throw;
            }
            finally
            {
                if (_isOwner)
                {
                    cnx.Dispose(); //Implicitly calls cnx.Close()
                }
                if (cmd != null) cmd.Dispose();
            }
        }


regards,
MS

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.