Link to home
Start Free TrialLog in
Avatar of aanuncio
aanuncio

asked on

Update data table using table adapter - stumped

C# newbie here. Can anyone tell me why I'm getting an error at "TextTypeT(0)" in the following line of code: "aanuncio.TextTypeTRow TextType = TextTypeT(0);"?

Here's the entire function:

[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public bool UpdateTextType(int TextTypeID, Nullable<int> SubjectAreaTextTypeID, string TextTypeNmI, string TextTypeNmII, string TextTypeNmIII, string TextTypeNmIV, Nullable<decimal> TextTypeRate, Nullable<decimal> TextTypeLagTime, bool TextTypePub)
        {

            aanuncio.TextTypeTDataTable TextTypeT = Adapter.GetTextTypeByTextTypeID(TextTypeID);

            if (TextTypeT.Count == 0)
            {
                return false;
            }

            aanuncio.TextTypeTRow TextType = TextTypeT(0);

            if (!SubjectAreaTextTypeID.HasValue)
            {
                TextType.SetSubjectAreaTextTypeIDNull();
            }
            else
            {
                TextType.SubjectAreaTextTypeID = SubjectAreaTextTypeID.Value;
            }

            TextType.TextTypeNmI = TextTypeNmI;

            TextType.TextTypeNmII = TextTypeNmII;

            TextType.TextTypeNmIII = TextTypeNmIII;

            TextType.TextTypeNmIV = TextTypeNmIV;

            if (!TextTypeRate.HasValue)
            {
                TextType.SetTextTypeRateNull();
            }
            else
            {
                TextType.TextTypeRate = TextTypeRate.Value;
            }

            if (!TextTypeLagTime.HasValue)
            {
                TextType.SetTextTypeLagTimeNull();
            }
            else
            {
                TextType.TextTypeLagTime = TextTypeLagTime.Value;
            }

            TextType.TextTypePub = TextTypePub;

            int rowsAffected = Adapter.Update(TextType);

            return rowsAffected == 1;
        }

Open in new window

Avatar of aanuncio
aanuncio

ASKER

The error in question is an Intellisense error: "Method name expected." This function was translated from VB.
can you provide the original VB.NEt code you attempted to translate ?
<System.ComponentModel.DataObjectMethodAttribute _
        (System.ComponentModel.DataObjectMethodType.Update, True)> _
    Public Function UpdateTextType _
    (ByVal TextTypeID As Integer, ByVal SubjectAreaTextTypeID As Nullable(Of Integer), ByVal TextTypeNmI As String, _
     ByVal TextTypeNmII As String, ByVal TextTypeNmIII As String, _
     ByVal TextTypeNmIV As String, _
     ByVal TextTypeRate As Nullable(Of Decimal), ByVal TextTypeLagTime As Nullable(Of Decimal), _
     ByVal TextTypePub As Boolean) _
     As Boolean

        Dim TextTypeT As aanuncio.TextTypeTDataTable = _
         Adapter.GetTextTypeByTextTypeID(TextTypeID)

        If TextTypeT.Count = 0 Then
            Return False
        End If

        Dim TextType As aanuncio.TextTypeTRow = TextTypeT(0)

        If Not SubjectAreaTextTypeID.HasValue Then
            TextType.SetSubjectAreaTextTypeIDNull()
        Else
            TextType.SubjectAreaTextTypeID = SubjectAreaTextTypeID.Value
        End If

        TextType.TextTypeNmI = TextTypeNmI

        TextType.TextTypeNmII = TextTypeNmII

        TextType.TextTypeNmIII = TextTypeNmIII

        TextType.TextTypeNmIV = TextTypeNmIV

        If Not TextTypeRate.HasValue Then
            TextType.SetTextTypeRateNull()
        Else
            TextType.TextTypeRate = TextTypeRate.Value
        End If

        If Not TextTypeLagTime.HasValue Then
            TextType.SetTextTypeLagTimeNull()
        Else
            TextType.TextTypeLagTime = TextTypeLagTime.Value
        End If

        TextType.TextTypePub = TextTypePub

        Dim rowsAffected As Integer = Adapter.Update(TextType)

        Return rowsAffected = 1
    End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of aanuncio
aanuncio

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This was a simple newbie error that I made because I'm not used to looking at C#. I'm surprised C# veterans didn't swoop on it.