Results 1 to 2 of 2

Thread: ado.net

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678

    ado.net

    do you know why I do not get the value for this field "FirstName" please?
    The depth of the datareader is 0 whereas it shows the correct fieldcount.

    public SqlDataReader PopulateSearch(string strDCTAnalyst, string strDateLogged, string strStatus, string strDateFixed, string strCountry)
    {
    string strSQL = "uspChangeRequest";
    string strConn = clsDataHandler.ConnectionString;

    SqlDataReader oDR;
    SqlCommand oCmd;
    SqlConnection oCon;

    try
    {
    oCon = new SqlConnection(strConn);
    oCmd = new SqlCommand(strSQL, oCon);

    oCmd.CommandType = CommandType.StoredProcedure;

    oCon.Open();
    oDR = oCmd.ExecuteReader(CommandBehavior.CloseConnection);

    if (oDR.Read() == true)
    {
    string x = oDR["LastName"].ToString();
    }

    return oDR;
    }

    catch (Exception ex)
    {
    throw ex;
    }
    }

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: ado.net

    FirstName ??? Isn't your code getting "LastName" field ??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width