在bloginfo数据库中,利用用户名 system 密码 scy251147 选择超级管理员登陆  创建如下存储过程:
/*存储过程*/


 

代码
create or replace procedure sys.InsertInfo
(
  TitleParams 
in nvarchar2,
  ContentParams 
in nvarchar2,
  Obj_Params out 
integer
)

is
begin
      
insert into testtable(ID,title,content)
      
values(seq_testtable_ids.nextval,TitleParams,ContentParams)

      
return ID into Obj_Params;

return;
exception
     
when no_data_found
       
then
            
null;
     
when others
       
then
            raise;
end InsertInfo;



 

然后就是asp.net端的操作代码:
 

代码
using(OracleConnection conn = new OracleConnection("Data Source=BlogInfo;User ID=System;Password=scy251147"))
{
    conn.Open();
    OracleCommand oracmd 
= new OracleCommand();
    oracmd.Connection 
= conn;
    DbParameter[] paras
=new OracleParameter[3];
   

    paras[
0= new OracleParameter("TitleParams", OracleType.NVarChar,500);
    paras[
0].Value = "你好啊,哈哈哈哈哈";
    paras[
0].Direction = ParameterDirection.Input;

    paras[
1= new OracleParameter("ContentParams", OracleType.NVarChar,500);
    paras[
1].Value = "我今天很高兴,真的,希望大家都要高兴啊,哈哈哈哈";
    paras[
1].Direction = ParameterDirection.Input;

    paras[
2= new OracleParameter("Obj_Params",OracleType.Int32);
    paras[
2].Direction = ParameterDirection.Output;

 

    oracmd.Parameters.Add(paras[
0]);
    oracmd.Parameters.Add(paras[
1]);
    oracmd.Parameters.Add(paras[
2]);

    oracmd.CommandText 
= "sys.INSERTINFO";

    oracmd.CommandType 
= CommandType.StoredProcedure;
   
    
    oracmd.ExecuteNonQuery();
    
int i = Convert.ToInt32(paras[2].Value);
    Response.Write(i.ToString());
}

 

从这里,我们看上去是一点问题都没有的,然后直接运行。
结果,一直提示“必须说明标识符“InsertInfo””(注意:我当时的语句是:oracmd.CommandText = "INSERTINFO";)
然后一直没找到结果,也没有发现程序中的错误,于是便想到了可能是授权的问题。
于是我退出超级管理员,然后利用用户名system 密码scy251147 选择Normal用户进行登陆,结果在利用
select * from testtable的时候,发现果真找不到这个表了,于是便利用select * from sys.testtable发现竟然显示
除了结果,于是便在语句前面加个sys.,一切正常了,返回了正确的数值。

猜想:可能是程序连接的时候,自动利用普通用户的权限进行登陆,而我的表是在超级管理员里面建立的,所以会看不到
只要在前面加上用户名称,就可以了,比如sys.testtabel。呵呵·~~~
小东西,看来里面的麻烦还不少。

posted on 2010-08-09 20:15  程序诗人  阅读(225)  评论(0编辑  收藏  举报