Use Parameters in the operation of the database

xiaoxiao2021-03-06  60

string conStr = "User Id = scott; Password = tiger; Data Source = oracle"; // Create the OracleConnectionOracleConnection con = new OracleConnection (conStr); con.Open (); // Create the OracleCommandOracleCommand cmd = new OracleCommand (); CMD.CONNECTION = con;

// Create OracleParameteroracleParameter [] PRM = New OracleParater [3];

// bind parametersprm [0] = cmd.Parameters.Add ("parameterdirection.input);

PRM [1] = cmd.Parameters.Add ("paramenetame", oracledbtype.varchar2, "client", parameterdirection.input);

PRM [2] = cmd.Parameters.Add ("paramdeptno", oracledbtype.decimal, 10, parameterdirection.input);

Cmd.commandtext = "INSERT INTO EMP (Empno, ENAME, Deptno) Values ​​(: 1,: 2,: 3)"

cmd.executenonquery ();

// Remove OracleParameter Objects from the collectcmd.parameters.clear ();

// Dispose OracleCommand Objectcmd.dispose ();

// Close and dispose OracleConnection Objectcon.Close (); con.pose ();

转载请注明原文地址:https://www.9cbs.com/read-91050.html

New Post(0)