public DataSet ExecuteDataSet() { DataSet dataSet; using (SqlConnection sqlConnection = new SqlConnection(Constants.Config.ConnectionString)) { SqlCommand sqlCommand = new SqlCommand(this.Name, sqlConnection); sqlCommand.set_CommandType(4); sqlCommand.set_CommandTimeout(120); IEnumerator enumerator = this.StoredProcParams.GetEnumerator(); try { while (enumerator.MoveNext()) { StoredProcParam storedProcParam = (StoredProcParam)enumerator.get_Current(); sqlCommand.get_Parameters().Add(storedProcParam.ParamID, storedProcParam.ParamValue); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } dataSet = new DataSet(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); sqlDataAdapter.Fill(dataSet); } return dataSet; }
public int ExecuteScalar() { int result = 0; using (SqlConnection sqlConnection = new SqlConnection(Constants.Config.ConnectionString)) { SqlCommand sqlCommand = new SqlCommand(this.Name, sqlConnection); sqlCommand.set_CommandType(4); sqlCommand.set_CommandTimeout(120); IEnumerator enumerator = this.StoredProcParams.GetEnumerator(); try { while (enumerator.MoveNext()) { StoredProcParam storedProcParam = (StoredProcParam)enumerator.get_Current(); sqlCommand.get_Parameters().Add(storedProcParam.ParamID, storedProcParam.ParamValue); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } sqlConnection.Open(); result = Convert.ToInt32(sqlCommand.ExecuteScalar()); sqlConnection.Close(); } return result; }
public static DataSet GetUser() { DataSet dataSet = new DataSet("User"); using (SqlConnection sqlConnection = new SqlConnection(Constants.Config.ConnectionString)) { SqlCommand sqlCommand = new SqlCommand("upGetUsers", sqlConnection); sqlCommand.set_CommandType(4); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); sqlDataAdapter.Fill(dataSet); } return dataSet; }
public static DataSet GetVehicleBuild(bool showAll) { DataSet dataSet = new DataSet("VehicleBuild"); using (SqlConnection sqlConnection = new SqlConnection(Constants.Config.ConnectionString)) { int num = Convert.ToInt32(showAll); SqlCommand sqlCommand = new SqlCommand("upGetVehicleBuilds", sqlConnection); sqlCommand.set_CommandType(4); sqlCommand.get_Parameters().Add("@ShowAll", num); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); sqlDataAdapter.Fill(dataSet); } return dataSet; }
public static DataSet GetParameterSets(int vehicleBuild, int buildType) { DataSet dataSet = new DataSet("Parameter"); using (SqlConnection sqlConnection = new SqlConnection(Constants.Config.ConnectionString)) { SqlCommand sqlCommand = new SqlCommand("upGetParameters", sqlConnection); sqlCommand.get_Parameters().Add("@VehicleBuildID", vehicleBuild); sqlCommand.get_Parameters().Add("@BuildType", buildType); sqlCommand.set_CommandType(4); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); sqlDataAdapter.Fill(dataSet); } return dataSet; }
private static System.Data.SqlClient.SqlCommand PrepareCommand(System.Data.SqlClient.SqlTransaction trans, string sql, System.Data.SqlClient.SqlParameter[] parameters) { System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(sql, Connection, trans); command.set_CommandType(System.Data.CommandType.Text); command.set_CommandTimeout(0); if (parameters != null) { command.Parameters.AddRange(parameters); } foreach (System.Data.SqlClient.SqlParameter parameter in command.Parameters) { if (parameter.get_Value() == null) { parameter.set_Value(System.DBNull.Value); } if ((parameter.SqlDbType == System.Data.SqlDbType.DateTime) && parameter.get_Value().Equals(new System.DateTime(1, 1, 1))) { parameter.set_Value(System.DBNull.Value); } } return command; }
public int ExecuteReturnVal() { int result = 0; using (SqlConnection sqlConnection = new SqlConnection(Constants.Config.ConnectionString)) { SqlCommand sqlCommand = new SqlCommand(this.Name, sqlConnection); sqlCommand.set_CommandType(4); sqlCommand.set_CommandTimeout(120); SqlParameter sqlParameter = new SqlParameter("@RETURN", 8); sqlParameter.set_Direction(6); sqlCommand.get_Parameters().Add(sqlParameter); IEnumerator enumerator = this.StoredProcParams.GetEnumerator(); try { while (enumerator.MoveNext()) { StoredProcParam storedProcParam = (StoredProcParam)enumerator.get_Current(); sqlCommand.get_Parameters().Add(storedProcParam.ParamID, storedProcParam.ParamValue); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } sqlConnection.Open(); sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); result = (int)sqlParameter.get_Value(); } return result; }
public static int GetVehicleBuildID(string vehicleInstID) { int result = 0; using (SqlConnection sqlConnection = new SqlConnection(Constants.Config.ConnectionString)) { SqlCommand sqlCommand = new SqlCommand("upGetVehicleBuildIDByVehicleInst", sqlConnection); sqlCommand.set_CommandType(4); sqlCommand.get_Parameters().Add("@VehicleInst", vehicleInstID); sqlConnection.Open(); result = Convert.ToInt32(sqlCommand.ExecuteScalar()); sqlConnection.Close(); } return result; }
public static DataSet GetVehicleInstParameters(string vehicleInstId) { DataSet dataSet = new DataSet("VehicleInst"); using (SqlConnection sqlConnection = new SqlConnection(Constants.Config.ConnectionString)) { SqlCommand sqlCommand = new SqlCommand("upGetVehicleInstParameters", sqlConnection); sqlCommand.set_CommandType(4); sqlCommand.get_Parameters().Add("@VehicleInstID", vehicleInstId); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); sqlDataAdapter.Fill(dataSet); } return dataSet; }
public static DataSet GetAdministrator(string userId) { DataSet dataSet = new DataSet("User"); using (SqlConnection sqlConnection = new SqlConnection(Constants.Config.ConnectionString)) { SqlCommand sqlCommand = new SqlCommand("upGetAdministrator", sqlConnection); sqlCommand.set_CommandType(4); sqlCommand.get_Parameters().Add("@UserID", userId); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); sqlDataAdapter.Fill(dataSet); } return dataSet; }