locked
Request for convert, Get Datarow of Datatable RRS feed

  • Question

  • User-518462008 posted

    hi guys 

    will you please convert this code to the C# for me ? 

     Dim dal As New DataLayerxsdTableAdapters.MemberTableAdapter
            Dim dt As DataLayerxsd.MemberDataTable = dal.GetDataByEmail_Password(Email, Password)
            If dt.Rows.Count > 0 Then
                Dim dr As DataLayerxsd.MemberRow = dt.Rows(0)
    
                Dim Name As String = dr.FirstName
    
    
            End If

    i already tried to convert in online and i got :

    DataLayerxsdTableAdapters.MemberTableAdapter dal = new DataLayerxsdTableAdapters.MemberTableAdapter();
    DataLayerxsd.MemberDataTable dt = dal.GetDataByEmail_Password(Email, Password);
    if (dt.Rows.Count > 0) {
    	DataLayerxsd.MemberRow dr = dt.Rows[0];
    
    	string Name = dr.FirstName;
    
    
    }

    but i faced to error :

    Error 5 Cannot implicitly convert type 'System.Data.DataRow' to 'DataLayerxsd.MemberRow'. An explicit conversion exists (are you missing a cast?)

    on this part : 

    dt.Rows[0];
    
    
    can any one help me , why ! 
    
    
    regards




    Thursday, August 30, 2012 1:27 AM

Answers

  • User3866881 posted

    DataLayerxsd.MemberRow dr = dt.Rows[0];

    Hi,

    In fact I think you can try this:

    DataLayerxsd.MemberRow dr = dt.Rows[0] as DataLayerxsd.MemberRow;
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 31, 2012 9:56 PM

All replies

  • User1455999623 posted

    Hi,

    As DataLayerxsd is your custom class.  What is the Typeof variable, MemberRow?  Can you paste the code of this custom class.

     

    Reply if any issues.

    Thursday, August 30, 2012 2:04 AM
  • User-518462008 posted
    Hi It is a dasaset.xsd file I have added my database table to .xsd file and named it DataLayer xsd Thanks
    Thursday, August 30, 2012 2:09 AM
  • User3866881 posted

    DataLayerxsd.MemberRow dr = dt.Rows[0];

    Hi,

    In fact I think you can try this:

    DataLayerxsd.MemberRow dr = dt.Rows[0] as DataLayerxsd.MemberRow;
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 31, 2012 9:56 PM