为什么我写的这个方法报错!高手进来看看
报错:
C:\Inetpub\wwwroot\Business\SheetNo.cs(34): “Business.SheetNo.CreateSheetNo(decimal, string, string, decimal, out string)” : 并非所有的代码路径都返回值
原代码:
public int CreateSheetNo(decimal cllyid,string clly, string jzy,decimal employeeid,out string retStr )
{//生成送货单编号(材料来源ID+用户ID+结帐月+4位流水号)
OleDbConnection cnn=null;
OleDbDataReader retRecord=null;
OleDbCommand objCmd=null;
string sqlStr=null;
retStr="";
if(jzy.Length!=6)
{
_ErrMsg="记帐月位数不够";
return -1;
}
else
{
try
{
cnn=new OleDbConnection(_cnnStr);
cnn.Open();
sqlStr="select max(sheetno) from twsheet where ifs is null and clly=?clly and jzy=?jzy and employeeid=?employeeid";
objCmd=new OleDbCommand(sqlStr,cnn);
objCmd.Parameters.Add("?clly",OleDbType.Numeric);
objCmd.Parameters.Add("?jzy",OleDbType.VarChar,10);
objCmd.Parameters.Add("?employeeid",OleDbType.Numeric);
objCmd.Parameters["?clly"].Value=cllyid;
objCmd.Parameters["?jzy"].Value=jzy ;
objCmd.Parameters["?employeeid"].Value=employeeid;
retRecord=objCmd.ExecuteReader();
while(retRecord.Read())
{
if(retRecord.Read())
{
System.Int64 xsl=Convert.ToInt64( retRecord.GetString(0))+1;
string xslxh=Convert.ToString(xsl);
retStr =clly+ employeeid + jzy + xslxh.Substring(xslxh.Length-4,4) ;
return 0;
}
else
{
retStr=clly + employeeid + jzy+"0001";
return 0;
}
}
}
catch(Exception e)
{
_ErrMsg=e.Message;
return -1;
}
finally
{
if(retRecord!=null)
retRecord.Close();
if(objCmd!=null)
objCmd.Dispose();
if(cnn!=null)
cnn.Close();
}
}
}
C:\Inetpub\wwwroot\Business\SheetNo.cs(34): “Business.SheetNo.CreateSheetNo(decimal, string, string, decimal, out string)” : 并非所有的代码路径都返回值
原代码:
public int CreateSheetNo(decimal cllyid,string clly, string jzy,decimal employeeid,out string retStr )
{//生成送货单编号(材料来源ID+用户ID+结帐月+4位流水号)
OleDbConnection cnn=null;
OleDbDataReader retRecord=null;
OleDbCommand objCmd=null;
string sqlStr=null;
retStr="";
if(jzy.Length!=6)
{
_ErrMsg="记帐月位数不够";
return -1;
}
else
{
try
{
cnn=new OleDbConnection(_cnnStr);
cnn.Open();
sqlStr="select max(sheetno) from twsheet where ifs is null and clly=?clly and jzy=?jzy and employeeid=?employeeid";
objCmd=new OleDbCommand(sqlStr,cnn);
objCmd.Parameters.Add("?clly",OleDbType.Numeric);
objCmd.Parameters.Add("?jzy",OleDbType.VarChar,10);
objCmd.Parameters.Add("?employeeid",OleDbType.Numeric);
objCmd.Parameters["?clly"].Value=cllyid;
objCmd.Parameters["?jzy"].Value=jzy ;
objCmd.Parameters["?employeeid"].Value=employeeid;
retRecord=objCmd.ExecuteReader();
while(retRecord.Read())
{
if(retRecord.Read())
{
System.Int64 xsl=Convert.ToInt64( retRecord.GetString(0))+1;
string xslxh=Convert.ToString(xsl);
retStr =clly+ employeeid + jzy + xslxh.Substring(xslxh.Length-4,4) ;
return 0;
}
else
{
retStr=clly + employeeid + jzy+"0001";
return 0;
}
}
}
catch(Exception e)
{
_ErrMsg=e.Message;
return -1;
}
finally
{
if(retRecord!=null)
retRecord.Close();
if(objCmd!=null)
objCmd.Dispose();
if(cnn!=null)
cnn.Close();
}
}
}
...全文
相关推荐
树莓派安装Opencv方法总结!包括各种报错解决方法!-附件资源
树莓派安装Opencv方法总结!包括各种报错解决方法!-附件资源
IDEA连接mysql报错的问题及解决方法
IDEA连接MySQL报错的问题及解决方法IDEA连接MySQL报错是开发中常见的问题,本文将详细介绍IDEA连接MySQL报错的问题及解决方法。
LINUX报错提示及解决方法.docx
强制执行)这是VIM编辑器中的另一个常见报错,出现这个报错是因为用户尝试编辑文件时,发现该文件是只读的,无法编辑。解决方法如下:1. 使用`:wq!`命令退出:使用`wq!
hive的一些报错及解决方法
### Hive的一些报错及解决方法#### 一、Hive连接报错在更换网络接口卡后重新启动服务时,可能会遇到Hive连接失败的问题。
摩托罗拉车载电台CM300M120常见写频报错故障的处理
**写频后修改项未生效**:确保修改后的参数已回写到机器。9. **多报错处理**:如果常规方法无效,可断电重启设备,或者尝试程序覆盖法修复。10. **其他不常见报错**:参考53#报错的处理方法。


