data retrieval with C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • awmb
    New Member
    • Jul 2006
    • 3

    data retrieval with C#

    I'm very new to .NET and C# and I'm having trouble retrieving information from a database. I'm trying to return the value of a field ("Name") from a DataTable using the code below, but I get the error message "not all code paths return a value" when I try to build.

    Where am I going wrong?

    public string GetVenueByID(in t id)
    {
    DataSet1.tblVen ueDataTable venue_top = new DataSet1.tblVen ueDataTable();
    DataSet1TableAd apters.tblVenue TableAdapter venue_top_info = new DataSet1TableAd apters.tblVenue TableAdapter();
    venue_top = venue_top_info. GetDataByID(id) ;

    if (venue_top.Coun t == 0)
    {
    return "xyz";
    }
    else
    {
    foreach (DataSet1.tblVe nueRow row in venue_top)
    {
    return row.Name;
    }

    }

    }
  • Elena
    New Member
    • Jul 2006
    • 3

    #2
    if (venue_top.Coun t == 0)
    {
    return "xyz";
    }
    else
    {
    if(venue_top.Ro ws.Count > 0 ){
    foreach (DataSet1.tblVe nueRow row in venue_top)
    {
    return row.Name;
    }
    }

    }

    }

    Comment

    Working...