I have this function in c# and a similar one in java, and I am trying to implement in Delphi, but can't figure how to do it
basically, instead of writing a bunch of code to build a query, assign it to a query component, clearing and setting the parameters, I want to build a parameterized query, add parameters, and call a function that does the clean up, open, error checking, etc.
the parameters will be different data types.
I did this in c# and java, so there's gotta be a way to do it in Delphi - pretty much the only thing I'm stuck on is the object list. I haven't used it before and can't seem to find a sample of how to do this, as all the samples seem to use a single object type...
is there a way to do this?
List<object> parms = new List<object>();
dbRoutines.execQuery("Update CustDocs Set CustUID = @p1, DateEdited = @p2 where RecordUID = @p3", parms);
the function -
public static Boolean execQuery([SqlFacet(MaxSize=-1)]String mySQL, List<object> parms)
Boolean result = true;
using (SqlConnection sqlConn =
new SqlConnection("Context Connection=True"))
SqlCommand sqlCmd = new SqlCommand("SET NOCOUNT ON; " + mySQL, sqlConn);
sqlCmd.CommandType = CommandType.Text;
for (int x = 0; x <= parms.Count - 1; x++)
sqlCmd.Parameters.Add(new SqlParameter("@p" + (x + 1).ToString(), parms[x]));//parameterValue)
SqlContext.Pipe.Send("Error Executing query " + Ex.GetType().ToString() + " " + Ex.Message);
result = false;