Why can't I see my tableadapters

johncassell

Well-known member
Joined
Jun 10, 2007
Messages
120
Location
Redcar, England
Programming Experience
Beginner
Hi There,

I have made a new form (Login.vb) and I am trying to call my UsersTableAdapter but the options are very limited.

when I type "me." I expect to see the tableadapter in the list of options but it is not there, nor are any of my other tableadapters.

Is this something to do with them not being Members of something?

Thanks

John
 
Ignore me,

Once again I spend half an hour looking for the answer and as soon as I post a question, literally the answer comes to me.

I dragged one of the datafields from my table onto the form which created the tableadapter for me underneath.

I thought the tableadapter already existed but I guess it needed to exist in my form as well.

Thanks anyway

John
 
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! :)
 
Thanks very much for that CJard, you are correct I didn't have a clue what the difference was. Your detailed explanation has helped a lot so I will avoid (or at least have some idea of) this problem in future.

Thanks again

John
 
Back
Top