I thought the tableadapter already existed but I guess it needed to exist in my form as well.
This kinda sounds like youre not sure of the difference between an Type and an instance. A Type is like a blueprint, an instance is a realized object conforming to that blueprint.
For example, we have a type Car
We can say Car.Drive() but Drive() would have to be a static(shared) method. Static isnt really how we do things in the OO world:
Dim x as New Car
Dim y as New Car
x and y are object instances of Type Car
and we say x.Drive, y.Drive
-
examples of a static method:
Dim x as String = String
.Format("the time is {0}", DateTime.Now) 'generates a string from the inputs, hence it doesnt make sense to require it be called on an existing string
examples of instance method:
Dim x as StringBuilder = "hello world"
x
.Replace("hello", "goodbye") ' replaces hello in existing instance, with goodbye
x
.ToString() 'generates a string out of the stringbuilder
-
One of the things I hate about VB the most, and why it turns out programmers who are somewhat looked down upon as being n00bish, is that it promotes confusion between Type and instance because it will create default instances of things like forms, using the same name as the type:
i.e. somewhere in hidden code in a hidden module that you never see is the line:
Public Shared
Form1 as New
Form1
So when you call:
Form1.Show()
You are actually calling it on the
INSTANCE, not the
TYPE, even though it looks like it.
This causes you further confusion when you try and say Me.XXXTableAdapter without ever creating an instance of it.
You must have an instance before you can call instance methods.. If you, or the IDE never wrote anywhere a line looking like:
Dim/Private/Public xyz as New XYZType
Then you cant use xyzinstance.
-
When you drag a tableadapter to a form the IDE writes this line for you (Its at the bottom of FormX.Designer.vb file which is merged with the FormX.vb file code)..
If youre still stuck with instances vs types, i recommend a good OO tutorial, and i apologise on behalf of M$ for being so stupid and misleading!