Once again I am calling on those more experianced then me for help. Here is the situration. I have an class called "SQLHelper" which contains the objects to make calls to the SQL Server (thanks to another on here for that). I am trying to pass 3 paramiters to one of the objects but keep getting the erro "No overload for method ExecSQLNonQeruy takes X arguments". Can someone look at it and tell me what is wrong? Thanks.
SQLHelper Code:
Calling code:Code:public static int ExecSQLNonQuery(string SQLQuery, string SingleParam, Array Params) { int RetVal = 0; using (SqlConnection Con = GetCon()) { SqlCommand cmd = new SqlCommand(); Con.Open(); { cmd.CommandText = SQLQuery; cmd.CommandType = CommandType.Text; cmd.Connection = Con; if (SingleParam == null) { cmd.Parameters.Add(SingleParam); } else { foreach (SqlParameter Param in Params) { cmd.Parameters.Add(Param) } } RetVal = cmd.ExecuteNonQuery(); } } return RetVal; }
I have also triedCode:using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Assignments_add : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { const string SQLStatment = "Insert into TaskList (Task, Status) values ('@Task', 'ToBeWorked')"; string[] Projects = txtProjects.Value.Split(';'); foreach (string Project in Projects) { SQLHelper.ExecSQLNonQuery(); } } } }
Code:SQLHelper.ExecSQLNonQuery(SQLStatment, Project, null);




Reply With Quote