本文整理汇总了C#中System.Data.SqlClient.SqlCommand.set_CommandType方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCommand.set_CommandType方法的具体用法?C# SqlCommand.set_CommandType怎么用?C# SqlCommand.set_CommandType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlCommand
的用法示例。
在下文中一共展示了SqlCommand.set_CommandType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteDataSet
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;
}
示例2: ExecuteScalar
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;
}
示例3: GetUser
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;
}
示例4: GetVehicleBuild
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;
}
示例5: GetParameterSets
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;
}
示例6: PrepareCommand
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;
}
示例7: ExecuteReturnVal
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;
}
示例8: GetVehicleBuildID
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;
}
示例9: GetVehicleInstParameters
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;
}
示例10: GetAdministrator
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;
}