Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    vancouver, BC, Br. Columbia
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    grappling with common programming problem (.NET framework 1.1)

    Hi Loungers,
    I have this line of code which works:

    this.clientDS.Tables["Contacts"].ImportRow(row);

    I have a lot of tables where I want to import a row, so I just want to pass a table into a method, like so:

    private void CopyDataTable(DataTable dataTable)
    {
    some code here
    this.calloutDS.Tables(dataTable.TableName.ToString ()).ImportRow(row);
    }
    any suggestions greatly appreciated.

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: grappling with common programming problem (.NET framework 1.1)

    I missed the question... Does your code not work? Or are you just looking for best-practice suggestions?

  3. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    vancouver, BC, Br. Columbia
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: grappling with common programming problem (.NET framework 1.1)

    Hi Mark - duh! I forgot to say that this line generates an error.

    this.calloutDS.Tables(dataTable.TableName.ToString ()).ImportRow(row);

    I get a compile-time error message which is incomprehensible to me: "Cannot apply indexing with [] to an expression of type 'System.Data.Dataset'.
    It works fine if I substitute a literal in quotes, e.g.

    this.calloutDS.Tables("Persons").ImportRow(row);

    But then I'd have to write a separate little routine for each table ... <img src=/S/barf.gif border=0 alt=barf width=64 height=23>

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: grappling with common programming problem (.NET framework 1.1)

    Try square brackets for the Table reference:

    this.calloutDS.Tables[dataTable.TableName.ToString()].ImportRow(row);

    If that doesn't work, try assigning the table name to a string variable then using the syntax above.

    Hope this helps <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  5. #5
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    vancouver, BC, Br. Columbia
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: grappling with common programming problem (.NET framework 1.1)

    I'm so happy I could jump for joy! Thank you - the square brackets worked! I'm so used to VBA that I never think of square brackets.

    Mark - do you have any words of wisdom about when to use square brackets?

    <img src=/S/coffeetime.gif border=0 alt=coffeetime width=32 height=48>

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: grappling with common programming problem (.NET framework 1.1)

    Switch to VB.Net and avoid them entirely?? <img src=/S/innocent.gif border=0 alt=innocent width=20 height=20> <img src=/S/duck.gif border=0 alt=duck width=23 height=23>
    Charlotte

  7. #7
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: grappling with common programming problem (.NET framework 1.1)

    Here's the helpfile contents for the [] operator, from Mcirosoft: http://msdn.microsoft.com/library/default....sref/html/vclrf[]operator.asp.

    To expand on Charlotte's post... I was curious why you're using C# since I think I remember that your background is mostly in the VB/VBA world? I used VB.NET exclusively until this year, when I discovered the inline documentation capabilities of C# (which will be added to VB.NET 2.0). However, I took a new job about 6 weeks ago that exclusively uses C# so I've learned to work with both. If someone were learning to program with no prior experience (or experience with C, C++ or Java), I would recommend C#. But for anyone who has experience with VB/VBA, I would definitely recommend VB.NET.

  8. #8
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    vancouver, BC, Br. Columbia
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: grappling with common programming problem (.NET framework 1.1)

    Hi Mark and Charlotte,
    I agree with you and like you am learning C# because my work demands it. I'm reading "Visual C#.Net : A guide for VB6 Developers". Wrox Press. I'm finding it very useful. I miss VB's case insensitivity. In the Wrox book it says, "Microsoft has developed this new langugage taking the best of many languages, making it easy and powerful, and has even used it to write the FCL. Microsoft is pushing to make C# the lead language for .NET programming."

    I'm having to learn so many new concepts: inheritance, polymorphism, constructors and destructors and namespaces, overloading, free threading, delegation - and these are all in VB.NET and C#.NET, so it doesn't seem a big burden to also learn a new, more elegant language, which takes the best of java and VB and other languagues.

    "in for a penny; in for a pound" ...whatever that means
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20>

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: grappling with common programming problem (.NET framework 1.1)

    <hr>"in for a penny; in for a pound" ...whatever that means<hr>
    It means you've been hanging out with the Brits in the Lounge too much! <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>
    Charlotte

  10. #10
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: grappling with common programming problem (.NET framework 1.1)

    I'm finding that the autocomplete (Control +space) plus naming standards can help towards case sensitivity. I was dreading it after earlier experience with C++ but I'm not finding it a big issue.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  11. #11
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: grappling with common programming problem (.NET framework 1.1)

    I recently discovered Ctrl + J for C#.... Works wonders!!

  12. #12
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: grappling with common programming problem (.NE

    Yes, C# is more difficult to use with Office than VB .NET.

    Hopefully, this difference will go away when Office is filly .NET-ized.
    Until then, I'm sticking with VB .NOT.

Posting Permissions

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