'mods.hasrows(string)':并非所有代码路径都返回值

编程入门 行业动态 更新时间:2024-10-27 20:35:58
本文介绍了'mods.hasrows(string)':并非所有代码路径都返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好, 我在类mods下声明了一个函数hasrows. 但它显示错误,即''.mods.hasrows(string)'':并非所有代码路径都返回值

Hello, i have declare one function hasrows under a class mods. but its showing error i.e.''mods.hasrows(string)'':not all code path return a value

public bool hasrows(string qry) { try { bool boo = false; OleDbCommand c = new OleDbCommand(qry, con); conn(); OleDbDataReader reader = c.ExecuteReader(); if (reader.HasRows == true) { reader.Close(); boo = true; } else { reader.Close(); boo = false; } c.Dispose(); return (boo); } catch (Exception ex) { //MsgBox(ex.Message) } }

推荐答案

您必须在catch中或catch外部指定一个返回值,以便在发生异常时代码路径有效. You have to specify a return value in your catch or outside your catch so the code path is valid when an exception occurs. ... catch (Exception ex) { //MsgBox(ex.Message) return false; // use this } return false; // or this }

更多推荐

'mods.hasrows(string)':并非所有代码路径都返回值

本文发布于:2023-11-10 01:22:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573977.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   返回值   代码   mods   string

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!