Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 21,886
Say or example I wanted to do this without parameters.
How would I pass in a blank parameter? Do I need to overload the function instead, without the params?
Code:
Sql = "Select firstName, Lastname, iDNumber from tblCustomers"
Code:
/// <method>
/// Select Query
/// </method>
public DataTable executeSelectQuery(String _query, SqlParameter[] sqlParameter)
{
SqlCommand myCommand = new SqlCommand();
DataTable dataTable = new DataTable();
dataTable = null;
DataSet ds = new DataSet();
try {
myCommand.Connection = openConnection();
myCommand.CommandText = _query;
myCommand.Parameters.AddRange(sqlParameter);
myCommand.ExecuteNonQuery();
myAdapter.SelectCommand = myCommand;
myAdapter.Fill(ds);
dataTable = ds.Tables(0);
} catch (SqlException e) {
Console.Write("Error - Connection.executeSelectQuery - Query: " + _query + " " + Constants.vbLf + "Exception: " + e.StackTrace.ToString());
return null;
} finally {
}
return dataTable;
}
How would I pass in a blank parameter? Do I need to overload the function instead, without the params?
Last edited: