troubleshooting Question

problems passing parameters

Avatar of N P
N P asked on
5 Comments1 Solution416 ViewsLast Modified:
Hi, I have a C# web project where I am trying to pass an array from one class to another, but I keep getting errors during build saying:

) expected
; expected
invalid expression term ")"

here is my code trying to pass SqlParameter array

            if (sortExpression.Length>0)
                    // get the last 3 or 4 character of expression to find sort direction
                    string direction = sortExpression.Substring(sortExpression.LastIndexOf(' ')+1, sortExpression.Length-sortExpression.LastIndexOf(' ')-1);
                    SqlParameter[] p = new SqlParameter[1];
                    p[0] = new SqlParameter("@direction", direction.ToString());
                    DataTable dt = Db.GetDataTable(sql.ToString(), SqlParameter p);     <======== it is having a problem with this statement

here is the class recieving the parameter

      public static DataTable GetDataTable(string sql, SqlParameter p)
            return GetDataSet(sql).Tables[0];

It got to be something simple that I am missing.


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros