-5
 private string Read_MDB_Acc(String acc)
    {   string myReturn;
        ...
        while (odrReader.Read())
                        {                            
                            myReturn = odrReader["acc"].ToString();


                        }


                        odrReader.Close();

                        odcConnection.Close();
    }
 return myReturn; //Show the myReturn doesn't not exist, how to solved?
4

2 回答 2

2

在不知道你的问题的情况下,为了编译,试试这个:

private string Read_MDB_Acc(String acc)
{
    string myReturn = String.Empty;
    // ...
    while (odrReader.Read())
    {                            
        myReturn = odrReader["acc"].ToString();
    }

    odrReader.Close();
    odcConnection.Close();

    return myReturn;
}
于 2013-03-22T12:28:56.103 回答
0

使用空字符串初始化myReturn 变量,例如:

private string Read_MDB_Acc(String acc)
    {   string myReturn = string.Empty;
        ...
        while (odrReader.Read())
                        {                            
                            myReturn = odrReader["acc"].ToString();


                        }


                        odrReader.Close();

                        odcConnection.Close();
                        return myReturn;
    }
于 2013-03-22T12:30:17.787 回答