本文整理汇总了C#中MySql.Data.MySqlClient.MySqlParameter.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlParameter.GetLength方法的具体用法?C# MySqlParameter.GetLength怎么用?C# MySqlParameter.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.MySqlClient.MySqlParameter
的用法示例。
在下文中一共展示了MySqlParameter.GetLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReader
/// <summary>
/// 通过存储过程得到DataReader对象
/// </summary>
/// <param name="spName">存储过程名称</param>
/// <param name="parms">存储过程参数数组</param>
/// <returns>SqlDataReader对象,失败为null</returns>
public MySqlDataReader GetReader(string spName, MySqlParameter[] parms)
{
try
{
Open();
Com = new MySqlCommand();
Com.Connection = Conn;
Com.CommandType = CommandType.StoredProcedure;
Com.CommandText = spName;
for (int intCounter = 0; intCounter < parms.GetLength(0); intCounter++)
{
Com.Parameters.Add(parms[intCounter]);
}
Dr = Com.ExecuteReader(CommandBehavior.CloseConnection);
return Dr;
}
catch (MySqlException)
{
return null;
}
finally
{
Com.Parameters.Clear();
}
}
示例2: ExecuteNonQuery
/// <summary>
/// 用于执行没有返回值的存储过程,包括Update,Insert,Delete
/// </summary>
/// <param name="pstrStoreProcedureName">存储过程名</param>
/// <param name="pParams">存储过程的参数数组</param>
/// <returns>执行结果:-1失败;其他:影响的行数</returns>
public int ExecuteNonQuery(string pstrStoreProcedureName, MySqlParameter[] pParams)
{
int Result;
try
{
if (Conn.State == ConnectionState.Closed)
{
Open();
}
Com = new MySqlCommand();
Com.Connection = Conn;
Com.CommandType = CommandType.StoredProcedure;
Com.CommandText = pstrStoreProcedureName;
for (int intCounter = 0; intCounter < pParams.GetLength(0); intCounter++)
{
Com.Parameters.Add(pParams[intCounter]);
}
Result = Com.ExecuteNonQuery();
}
catch (MySqlException)
{
return -1;
}
finally
{
Com.Parameters.Clear();
Com.Dispose();
Close();
Conn.Dispose();
}
return Result;
}
示例3: GetDataSet
/// <summary>
/// 调研存储过程得到DataSet
/// </summary>
/// <param name="spName">存储过程名</param>
/// <param name="parms">存储过程参数数组</param>
/// <returns>Dataset对象,失败为null</returns>
public DataSet GetDataSet(string spName, MySqlParameter[] parms)
{
try
{
Open();
Adp = new MySqlDataAdapter(spName, Conn);
Adp.SelectCommand.CommandType = CommandType.StoredProcedure;
for (int intCounter = 0; intCounter < parms.GetLength(0); intCounter++)
{
Adp.SelectCommand.Parameters.Add(parms[intCounter]);
}
Ds = new DataSet();
Adp.Fill(Ds, "ds");
return Ds;
}
catch (MySqlException)
{
return null;
}
finally
{
Adp.SelectCommand.Parameters.Clear();
Adp.Dispose();
Close();
}
}