dcsimg
Page 2 of 2 FirstFirst 12
Results 41 to 61 of 61

Thread: [RESOLVED] System.InvalidCastException

  1. #41

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: System.InvalidCastException

    You nailed it Mike!!! Works like a champ. Now I need to find out what bunwad took the datasource and member out of my binding source. I absolutely could not have been me. I swear to God!!!

  2. #42
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: System.InvalidCastException

    Naaa.... was probably the whyskie

  3. #43

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: System.InvalidCastException

    Whiskey would never do that to me. It was some bunwad who sneaked in and took out the settings while I was doing something else. Anyway man, you performed a miracle here. Have you thought about applying for Jesus's job?

  4. #44
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: System.InvalidCastException

    Anyway i took the time to do some reshearch on this, i have been usint that metothe for a long time, and when something works, i move one to something else, now that i read a litle more about it aparently everyone recoments to use the datatable not the binding source, so i will post some code here, give a few minutes.

  5. #45
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: [RESOLVED] System.InvalidCastException

    This does produces the same result and as far as i read on the matter its the recomended way to do it:


    Code:
    Dim YourTable As DataTable = YourDataSet.Tables("YourTableName")
                Dim New_Row As DataRow = YourTable.NewRow
    
                With New_Row
                    .Item("ColumeName") = "To your value"
                End With
               
                 YourTable.Rows.Add(New_Row)
    Last edited by Mike Storm; Oct 2nd, 2017 at 06:44 PM. Reason: YourTable.Rows.Add(New_Row) was missing, dam copy/past

  6. #46

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: [RESOLVED] System.InvalidCastException

    That looks suspiciously similar to this:

    Code:
                        Dim NewTrainingRow As _MasterBase4_0ItemMasterDataSet.tblChangeTrainRow
                        NewTrainingRow = _MasterBase4_0ItemMasterDataSet.tblChangeTrain.NewtblChangeTrainRow()
                        NewTrainingRow.intChangeID = glbintCRNum
                        NewTrainingRow.StrName = _MasterBase4_0ItemMasterDataSet.tblEmployee(intCountRow).strFullName
                        _MasterBase4_0ItemMasterDataSet.tblChangeTrain.Rows.Add(NewTrainingRow)
    Not exactly the same, but similar. I do know that you can do it this way without worrying about the binding sources.

  7. #47
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: [RESOLVED] System.InvalidCastException

    Yes, it is similar to that, from what i have been reading its a better aprouche, i have been using the other code i give for a couple of time, never had trouble with it, so i was kinda, how the is that happening? It took me a while to figure it out, couse from the previews posts i had the impression you draged the objects in designer, soo they have it's properties set by default.

  8. #48
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: [RESOLVED] System.InvalidCastException

    You can also get it done like this:

    Code:
    Dim rw = YourTable.Rows.Add(
                    New Object() {Nothing, "Value 3"})
    But since you will be getting the values from a binding source or aternatively from a datagridview, it would become a pretty long line of code what is complicated to review and understand

  9. #49

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: [RESOLVED] System.InvalidCastException

    I think I am going to use both approaches. I am also going to stick them both into my Code snippets file.

    No, I did not drag them in. I got the binding sources from the tools window and you have to set them when you do that. Obviously someone came in and took my settings out since I would never forget to do that.

  10. #50
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: [RESOLVED] System.InvalidCastException

    Lol....

  11. #51
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: [RESOLVED] System.InvalidCastException

    As a matter of curiosity, Access database:


    https://support.office.com/en-us/art...8-98c1025bb47c

    If you think 10Gb database in SQL its too litle, the you gona have a stroke when you look at the above.
    I couldnt precise this couse i dont work with any of the programs contained in Office Suite.

  12. #52

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: [RESOLVED] System.InvalidCastException

    That figures. They are out to get us all and squeeze us dry. I have started looking at the SQL. That is going to take a little while. The damn thing is confusing as hell with it's field datatypes and what has pissed me off so far is that once I save a table the damn thing won't let me go back in and change the datatypes! I am sure there is a way around that, but I haven't looked at this enough to have any idea how. By the way, there appears to be no Boolean datatype. I like those and use them quite a bit. Seems like everything you do ends up being a compromise. Kind of like marriage except instead of compromise it is capitulation.

  13. #53
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: [RESOLVED] System.InvalidCastException

    Boolean = bit (have seen some other ways, this is what i use) pretty strait foawrd vs will create a check box for it.
    Change datatypes you need to change a setting:

    https://imgur.com/a/upImb

  14. #54
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: [RESOLVED] System.InvalidCastException

    Now, you need to know that using that off, can couse loss of data if you attempt to change something on a table that has already data in.
    Last edited by Mike Storm; Oct 2nd, 2017 at 08:27 PM.

  15. #55
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

  16. #56

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: [RESOLVED] System.InvalidCastException

    Thanks Mike. I already bought some books and am not happy with any of them.

  17. #57

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: [RESOLVED] System.InvalidCastException

    By the way, while I was reading some of the material I got yesterday I saw where the text datatype is going to be phased out and it is suggested that it not be used anymore. FYI

  18. #58
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: [RESOLVED] System.InvalidCastException


  19. #59

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: [RESOLVED] System.InvalidCastException

    Yeah that was my plan. Since I am just starting I will start text datatype free. Also, I found the Boolean datatype (thanks to your info). It is the bit datatype. Whew!

  20. #60
    Hyperactive Member Mike Storm's Avatar
    Join Date
    Jun 2017
    Location
    Belgium
    Posts
    425

    Re: [RESOLVED] System.InvalidCastException

    And the link i posted https://imgur.com/a/upImb , you have to uncheck that to be able to change the datatypes.
    And im off for today, just finish what i was doing, enjoy your reading

  21. #61

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    471

    Re: [RESOLVED] System.InvalidCastException

    Damn, I went all through the options and never did see that. Thanks, I needed that.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width