|
-
Oct 2nd, 2017, 06:28 PM
#41
Thread Starter
Fanatic Member
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!!!
-
Oct 2nd, 2017, 06:29 PM
#42
Hyperactive Member
Re: System.InvalidCastException
Naaa.... was probably the whyskie
-
Oct 2nd, 2017, 06:32 PM
#43
Thread Starter
Fanatic Member
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?
-
Oct 2nd, 2017, 06:32 PM
#44
Hyperactive Member
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.
-
Oct 2nd, 2017, 06:42 PM
#45
Hyperactive Member
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
-
Oct 2nd, 2017, 06:48 PM
#46
Thread Starter
Fanatic Member
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.
-
Oct 2nd, 2017, 06:52 PM
#47
Hyperactive Member
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.
-
Oct 2nd, 2017, 06:55 PM
#48
Hyperactive Member
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
-
Oct 2nd, 2017, 06:56 PM
#49
Thread Starter
Fanatic Member
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.
-
Oct 2nd, 2017, 06:57 PM
#50
Hyperactive Member
Re: [RESOLVED] System.InvalidCastException
-
Oct 2nd, 2017, 07:20 PM
#51
Hyperactive Member
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.
-
Oct 2nd, 2017, 07:41 PM
#52
Thread Starter
Fanatic Member
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.
-
Oct 2nd, 2017, 07:46 PM
#53
Hyperactive Member
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
-
Oct 2nd, 2017, 07:48 PM
#54
Hyperactive Member
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.
-
Oct 2nd, 2017, 07:54 PM
#55
Hyperactive Member
Re: [RESOLVED] System.InvalidCastException
-
Oct 2nd, 2017, 08:01 PM
#56
Thread Starter
Fanatic Member
Re: [RESOLVED] System.InvalidCastException
Thanks Mike. I already bought some books and am not happy with any of them.
-
Oct 2nd, 2017, 08:12 PM
#57
Thread Starter
Fanatic Member
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
-
Oct 2nd, 2017, 08:15 PM
#58
Hyperactive Member
Re: [RESOLVED] System.InvalidCastException
-
Oct 2nd, 2017, 08:29 PM
#59
Thread Starter
Fanatic Member
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!
-
Oct 2nd, 2017, 08:31 PM
#60
Hyperactive Member
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
-
Oct 2nd, 2017, 08:33 PM
#61
Thread Starter
Fanatic Member
Re: [RESOLVED] System.InvalidCastException
Damn, I went all through the options and never did see that. Thanks, I needed that.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|