Home > database >  How to call the variables into a stored procedure
How to call the variables into a stored procedure

Time:09-16

I wrote a check of the stored procedure:
The CREATE OR REPLACE PROCEDURE QUERY_WORD
(WORD_IN IN WORD. The WORD % TYPE, ID_IN IN WORD. ID % TYPE, TRANS_OUT OUT WORD. TRANSLATION % TYPE)
As trans varchar2 (100);
The BEGIN
The SELECT translation into trans FROM WORD WHERE WORD=WORD_IN AND ID=ID_IN;
TRANS_OUT:=trans;
END QUERY_WORD;
Use VS2012 call is as follows:
SQL. The Format (_T (" call QUERY_WORD (' % s', '% s',' % s');" ), the word, id, translation);
TRACE (SQL);
M_db. The ExecuteSQL (SQL);
Operation error is not bind variables, how to call in to a stored procedure can be introduced into variable translation

CodePudding user response:

String ss=DateTime. Now. The ToString ();
String STR="Data Source=. Uid=sa; The PWD=1107; Integrated Security=SSPI; The database=05-08-2014; Integrated Security=True ";
Conn=new SqlConnection (STR);
If (conn. State==ConnectionState. Closed)
{
Conn. The Open ();
}
SqlCommand CMD=new SqlCommand (" stored procedure name '", conn);
Cmd.Com mandType=CommandType. StoredProcedure;
CMD. The Parameters. The Add (" Parm1 ");
"Parm1" CMD. The Parameters [] Direction=ParameterDirection. Input;
CMD. The Parameters [r]. "Parm1" Value=https://bbs.csdn.net/topics/ss;
CMD. ExecuteNonQuery ();

CodePudding user response:

reference 1st floor lzp_lrp response:
string ss=DateTime. Now. The ToString ();
String STR="Data Source=. Uid=sa; The PWD=1107; Integrated Security=SSPI; The database=05-08-2014; Integrated Security=True ";
Conn=new SqlConnection (STR);
If (conn. State==ConnectionState. Closed)
{
Conn. The Open ();
}
SqlCommand CMD=new SqlCommand (" stored procedure name '", conn);
Cmd.Com mandType=CommandType. StoredProcedure;
CMD. The Parameters. The Add (" Parm1 ");
"Parm1" CMD. The Parameters [] Direction=ParameterDirection. Input;
CMD. The Parameters [r]. "Parm1" Value=https://bbs.csdn.net/topics/ss;
CMD. ExecuteNonQuery ();


To get the result returned with executereader ()
  • Related