create procedure myProc(v_JQ varchar(50),out flg int)
begin
declare SYID,JQID,MyNewId int default 0;
set flg=1;
select id into JQID from insorder where insDocumentId=v_JQ and `status`='新数据'  limit 0,1;
set flg=JQID;
end在MYSql查询分析器里执行运行正常。可是通过C#程序调用该存储过程,flg则为0,并且select id是有值的,如果set flg=v_JQ 则返回我传入的值

解决方案 »

  1.   

    现在测试用程序执行存储过程
    if  exists(select 1 from insorder where `status`='新数据'  ) then 
     set flg=10;
    else
    set flg=11;
            end if;
    永远返回11 
    而直接在查询分析器里执行select 1 from insorder where `status`='新数据' 出现1
      

  2.   

    create procedure myProc(v_JQ varchar(50),out flg int)
    begin
    declare SYID,JQID,MyNewId int default 0;
    select id into flg from insorder where insDocumentId=v_JQ and `status`='新数据'  limit 0,1;
    end call myproc('123',@ee);
    select @ee结果是否正确
      

  3.   

    在查询分析器里是正确的
    可是用程序调用 就不正确了
    刚才我查出原因了,是`status` 这个关键字的问题的,我如果把这个条件去掉,就正确了,可现在这个条件不能去,并且这个字段名是MYSql中的关键字,
    有解决办法吗?
      

  4.   

    …… 
    Cmd.CommandText = "pop_test";
     Cmd.CommandType = CommandType.StoredProcedure;
    Cmd.Parameters[0].Direction = ParameterDirection.Output;
    if (Cmd.Connection.State == 0)
     Cmd.Connection.Open();
    Cmd.ExecuteNonQuery();
    label1.Text += Cmd.Parameters[0].Value + "\r\n";
    ……
      

  5.   

    …… 
    Cmd.CommandText = "pop_test"; 
    Cmd.CommandType = CommandType.StoredProcedure; 
    Cmd.Parameters.Add("?flg", MySqlDbType.Int16);//, 50);
    Cmd.Parameters[0].Direction = ParameterDirection.Output; 
    if (Cmd.Connection.State == 0) 
    Cmd.Connection.Open(); 
    Cmd.ExecuteNonQuery(); 
    label1.Text += Cmd.Parameters[0].Value + "\r\n"; 
    ……
      

  6.   

    现在又检测到不是关键字的问题
    begin
    if  exists(select 1 from insorder where id=21053) then 
     set flg=10;
    else
    set flg=11;
            end if;
    end
    上面返回10
    而下面的则返回11
    begin
    if  exists(select 1 from insorder where financialVerifyPerson='赵全华') then #financialVerifyPerson字段中有赵全华这样的记录
     set flg=10;
    else
    set flg=11;
            end if;
    end
      

  7.   

    create procedure myProc(v_JQ varchar(50),out flg int) 
    begin 
    declare SYID,JQID,MyNewId int default 0; 
    set flg=1; 
    select id into JQID from insorder where insDocumentId=v_JQ and `status`='新数据'  limit 0,1; 
    set flg=JQID; 
    end …… 
    Cmd.CommandText = "pop_test"; 
    Cmd.CommandType = CommandType.StoredProcedure; 
    Cmd.Parameters[0].Direction = ParameterDirection.Output; 
    if (Cmd.Connection.State == 0) 
    Cmd.Connection.Open(); 
    Cmd.ExecuteNonQuery(); 
    label1.Text += Cmd.Parameters[0].Value + "\r\n"; 看一下,你的myProc有几个参数???你传了几个参数? 参数[0]对应的是哪个参数?9楼 更是不知道你想说什么?你自己运行一下
    select 1 from insorder where id=21053;
    select 1 from insorder where financialVerifyPerson='赵全华';
    不就什么都知道了,根本没有 '赵全华'
      

  8.   

    问题已经解决,原来是status`='新数据'  或 financialVerifyPerson='赵全华'中中文的问题,需要在中文前面加_utf8来转换一下