Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQLParameter converting to integer
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
SQLParameter converting to integer
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01326205
Message ID:
01326205
Views:
73
Hi everybody,

I'm wondering what is the proper syntax to use.

I have two integer parameters in my SP. One is Input, another is Output.

Here is the code I'm trying
SqlParameter[] parameters = new SqlParameter[2];
                        parameters[0] = new SqlParameter("RegistrationID", RegID);
                        parameters[1] = new SqlParameter("PersonID", 0);
                        parameters[1].Direction = ParameterDirection.Output ;
I then need to use the value of output parameter and pass it to a different function. I'm wondering what is the good way of casting the value to integer. May be I can specify it as an integer in the constructor?

I also have another question. Does it make sense to put declaration
SqlParameter[] parameters = new SqlParameter[2];

outside the loop?

The whole code I'm trying is:
GridViewRow row = null; 
            for (int i = 0; i < this.ProfilesGrid.Rows.Count; i++ )
            {
                row = this.ProfilesGrid.Rows[i];
               
                CheckBox chkbtnApproved = row.FindControl("chkApproved") as CheckBox ;

                if (chkbtnApproved != null)
                {
                    if (chkbtnApproved.Checked == true)
                    {
                        int RegID = (int)this.ProfilesGrid.DataKeys[i].Value ;
                        
                        //PersonName = row.Cells[  ["FirstName"] + " " + row["LastName"];
                        PersonName = "test";
                        //PersonName = ((TextBox)row.FindControl("FirstName")).Text + " " + ((TextBox)row.FindControl("LastName")).Text;
                        
                        SqlParameter[] parameters = new SqlParameter[2];
                        parameters[0] = new SqlParameter("RegistrationID", RegID);
                        parameters[1] = new SqlParameter("PersonID", 0);
                        parameters[1].Direction = ParameterDirection.Output ;   
                        
                        //new System.Data.SqlClient.SqlParameter("RegistrationID", RegID)
                        Util.RunStoredProc("SaveApprovedPerson", parameters);
                        MessageText = "Dear " + PersonName + ", " +
                                      Environment.NewLine + Environment.NewLine + "Your Registration has been approved! " +
                                      Environment.NewLine + Environment.NewLine + "Welcome to ...!";
                        Util.SendMessage(parameters[1].Value, Membership.GetUser(),
                        false, MessageText, "Registration Approved", System.Configuration.ConfigurationManager.AppSettings["devEmail"] );
                        PeopleApproved++;
                    }
                }
            }
Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform