smhy8187

 

控制离开当前方法之前必须对输出参数“_ageUserName”赋值

public void replyPrivateMessage(string id1,out string _askTime,out string _askTitle,out string _askContent,out string _ageUserName)
  {
   try
   {
    //get reply detail
    c.OpenData4();
    string sqlReader="select * from shortMessage where id="+id1;
    OleDbCommand cmd=new OleDbCommand(sqlReader,c.mdbconn4);
    OleDbDataReader dr=cmd.ExecuteReader();

    _askTime = "";//
    _askTitle = "";//
    _askContent = "";//
    _ageUserName = "";//

    if(dr.Read())//假如if 为false  则没有返回值,所以在if外需要加//部分的初始值
    {
     _askTime = dr["askTime"].ToString();
     _askTitle = dr["askTitle"].ToString();
     _askContent = dr["askContent"].ToString();
     _ageUserName = dr["ageUserName"].ToString();
 
    }
    dr.Close();
    c.mdbconn4.Close();
   
   
   }
   catch(Exception ex)
   {
                
     c.mdbconn4.Close();
    _askTime = "";
    _askTitle = "";
    _askContent = "";
    _ageUserName = "";
   
   }
  
  }

posted on 2007-05-18 16:18  new2008  阅读(1208)  评论(0编辑  收藏  举报

导航