Esh*_*sha 3 c# asp.net dataset sqldataadapter
我已经定义了以下函数,它将从表中返回3列.
public DataSet GetFunc()
{
int iRet = 0;
DataSet ds = new DataSet();
SqlConnection sqlConnection = new SqlConnection();
try
{
iRet = connect(ref sqlConnection);
if (DB_SUCCESS_CONNECT == iRet)
{
SqlCommand sqlCommand = new SqlCommand("", sqlConnection);
String strQuery = "Select ID, Did, FirstName from Users";
sqlCommand.CommandText = strQuery;
SqlDataAdapter adaptor = new SqlDataAdapter(sqlCommand);
adaptor.Fill(ds);
sqlConnection.Close();
return ds;
}
}
catch (Exception e)
{
disconnect(ref sqlConnection);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试构建它时,我收到错误:
错误172'GetFunc()':并非所有代码路径都返回一个值
我很困惑我哪里出错了.有人可以指导我吗?