OleDbParameter[] signParms = new OleDbParameter[] {
new OleDbParameter(PARM_IN,OleDbType.VarChar ,50),//輸入參數
new OleDbParameter(PARM_OUT , OleDbType.VarChar,100 )};//輸出參數
signParms[0].Value = "";
signParms[0].Direction = ParameterDirection.Input;
signParms[1].Direction = ParameterDirection.Output;
OracleHelper.ExecuteNonQuery(OracleHelper.ConnString, CommandType.StoredProcedure, PROCEDURE_NAME, signParms);
public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params OleDbParameter[] commandParameters)
{
OleDbCommand cmd = new OleDbCommand();
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
}
private static void PrepareCommand(OleDbCommand cmd, OleDbConnection conn, OleDbTransaction trans, CommandType cmdType, string cmdText, OleDbParameter[] commandParameters)
{
if (conn.State != ConnectionState.Open)
conn.Open();
cmd.Connection = conn;
cmd.CommandText = cmdText;
cmd.CommandType = cmdType;
if (trans != null)
cmd.Transaction = trans;
if (commandParameters != null)
{
foreach (OleDbParameter parm in commandParameters)
cmd.Parameters.Add(parm);
}
}
楼上正解。
SqlHelper是一个很好的封装应用实例
http://www.cnblogs.com/xiefang1980/archive/2008/03/10/1098938.html
http://www.51aspx.com/SqlHelper-1.html
http://www.cnblogs.com/eebb/archive/2007/04/10/706650.html
在数据库里学习其基本的语法,定义好存储过程,在VS里调用如楼1