本文整理匯總了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();
}
}