General information
Category:
Coding, syntax and commands
Title:
Not all code returns a value
Environment versions
Network:
Windows 2003 Server
I keep recieving an error telling me not all code paths return a value, though I'm pretty sure I have it covered? I just cant see what I'm missing here, I think I have everything returning a value.
private string sqlreturn(string cmd,string search_item)
{
//this method returns a value for the item thats passed
SqlConnection con1 =new SqlConnection(connection);
SqlCommand cmd1 = new SqlCommand(cmd,con1);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.Add(new SqlParameter("@search_item", SqlDbType.VarChar));
cmd1.Parameters["@search_item"].Value = search_item;
SqlDataAdapter searchs = new SqlDataAdapter(cmd1);
con1.Open();
DataSet search = new DataSet("search");
searchs.Fill(search, "search");
con1.Close();
DataView dv = new DataView(search.Tables[0]);
if (cmd.Trim().Equals("sp_PMreturn_item"))
{
foreach (DataRowView drv in dv)
{
return drv["itmdesc"].ToString().Trim();
}
}
else
{
return "";
}
}
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only