Noob Question: Where Does A "TableAdapter" Live?

P

(PeteCresswell)

I'm going through MS's "DataValidation" sample, which uses the
NorthWind DB.

When I try to debug, it throws an error at
"Me.Order_DetailsTableAdapter.Fill(Me.NorthwindDataSet.Order_Details)"

The error being "A network-related or instance-specific error
occurred while establishing a connection to SQL Server. The
server was not found or was not accessible. Verify that the
instance name is correct and that SQL Server is configured to
allow remote connections. (provider: Named Pipes Provider, error:
40 - Could not open a connection to SQL Server)"

Seems to me like I need to edit "Order_DetailsTableAdapter" and
figure out why it's not connecting.

I'm able to drill down to "CommandText" - which seems tb the SQL
for the "Fill and "GetData" methods, but can't find where it
points to the DB.

Also, when I try to "Preview Data" it throws the same "...server
not found..." message - as tb expected, I guess....


OTOH, I am able to open NORTHWNDDataSet.xsd and see the
relationships diagram and, after doing a Tools | Connect To
Database, I can see the data in the table in question.

So it seems like "Order_DetailsTableAdapter" has something in it
or points to something that's not hooked into the DB properly.

Can anybody point me in the right direction?
 
S

Scott M.

A TableAdapter is a special construct created by Visual Studio and you can
see it visually by opening your .xsd file. If you simply click on it and
look at its properties, you'll see the "connection" property, which if you
expand it, you'll see the "connectionstring" property. This is the property
that contains all the information about connecting to your data source.

-Scott
 
P

(PeteCresswell)

Per Scott M.:
A TableAdapter is a special construct created by Visual Studio and you can
see it visually by opening your .xsd file. If you simply click on it and
look at its properties, you'll see the "connection" property, which if you
expand it, you'll see the "connectionstring" property. This is the property
that contains all the information about connecting to your data source.

That's kind of what I was expecting - but mine doesn't show a
"ConnectionString" prop.

Instead, it shows a "FileName" and a "FullPath", which I'm
guessing are functional equivalents.

viz: http://tinyurl.com/y9z3qe3

Or am I still looking in the wrong place?
 
S

Scott M.

Or am I still looking in the wrong place?

Yes, you are looking in the wrong place.

The picture you show is the properties for your Fill Query. Do you see that
it says "Fill Query" at the top of your properties window?

If you do a single, left mouse click, directly on the word
"ProductsTableAdapter" in the diagram, your properties window will show you
the properties for this TableAdapter. In that list, there will be a
"Connection" property, which you can expand to expose the "ConnectionString"
property, which contains the information on the type of database you are
connecting to, where it is, and what credentials to use to connect to it.

Now, having said all that, if you have created a Data Connection in the
Server Explorer window first, and just dragged out the table(s) you are
interested in, then the ConnectionString should be configured properly for
you.

-Scott
 
P

(PeteCresswell)

Per Scott M.:
If you do a single, left mouse click, directly on the word
"ProductsTableAdapter" in the diagram, your properties window will show you
the properties for this TableAdapter. In that list, there will be a
"Connection" property, which you can expand to expose the "ConnectionString"
property, which contains the information on the type of database you are
connecting to, where it is, and what credentials to use to connect to it.

Bingo! Thanks.

For some reason, I had been assuming that those brown areas were
just headers.

Now, having said all that, if you have created a Data Connection in the
Server Explorer window first, and just dragged out the table(s) you are
interested in, then the ConnectionString should be configured properly for
you.

Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top