040908 Q SQL Statement In SqlServer & Oracle --Select Top 0 * from & Rownum = 0

xiaoxiao2021-03-06  66

1.String strsql = "SELECT TOP 0 * from" strtblname;

OracleDataAdapter Oraadapter = New OracleDataAdapter ();

Oraadapter.selectCommand = getoracommand (strsql); // new OracleCommand

DataTable DT = New DataTable ();

Oraadapter.fillschema (DT, System.Data.schematype.mapped);

// error: ORA-00923: from キ キ ワ ワ が が が 位置 位置 に あ あ せ.. / N

When using SqlClient, oracle is wrong. why?

A: Oracle uses where rownum = 0

2. Use OracleParameter's SQL statement in 2. Oracle

DataTable dt = new DataTable (); string ConnectString = "server = ibm2d; uid = ibm2d; pwd = ibm2d; Data Source = ibm2d"; string strSQL = "SELECT * FROM JS_KOJIN_TBL WHERE KJNNO =: KJNNO"; // SqlServer in use Kjnno = @Kjnno OracleConnection Conn = New OracleConnection; conn.open ();

OracleCommand cmd = new OracleCommand (strSQL, conn); cmd.CommandType = CommandType.Text; OracleDataAdapter oraAdapter = new OracleDataAdapter (); oraAdapter.SelectCommand = cmd; oraAdapter.SelectCommand.Parameters.Add ( ": KJNNO", OracleType.VarChar, 4, "kjnno"); oraadapter.selectcommand.parameters [": kjnno"]. Value = "1099"; Oraadapter.Fill (DT);

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

New Post(0)