Can't find class TableAdapterManager in visual studio express 2010 - vb.net

I tried to use this code
Dim Manager1 As New TableAdapterManager()
But it's seem to can't find TableAdapterManager.
Is this class not supported for visual studio express 2010?

That's not how you use a table adapter manager. It is part of a typed DataSet and, just like everything else in a typed DataSet, it gets generated by VS when you create a Data Source.
Use the Data Sources window in VS to create a new Data Source and specify that you want to create a DataSet for your database. That will generate a typed DataSet including a typed DataTable for each table in the database. There will also be a table adapter for each DataTable and a table adapter manager that allows you to save changes using multiple table adapters at once.
You can drag those items from the Toolbox to your form in the designer or you can create them in code. If you create them in code, there will be a namespace dedicated to the table adapters of your DataSet so you must either qualify the type names with that namespace or else import it, just like any other namespace.

Related

remove all fully qualified names from a database

I have a database, lets say AP, some of its objects use fully qualified names like,
select * from AP.dbo.Customer
I restored this database to another machine and renamed the database to APDev, but now all the fully qualified name object references don't work, is there a simple way to remove all the qualified name.
Thanks
After you restore the database to New Database say APDev, Generate the SQL Script for all DB object for this new APDev database, then Replace AP to APDev or Remove it, then execute again this Updated/Modified SQL script on new database. Then All object will be restored with new name.
To Generate the SQL Script from New APDev Database,
In Object Explorer, expand Databases, right-click a database, point to Tasks,
and then click Generate Scripts. Follow the steps in the wizard
to script the database objects.
To See how to Generate Script, Follow http://technet.microsoft.com/en-us/library/ms178078(v=sql.105).aspx

SSIS - using VB to dynamically create ole db source where the SQL source is too dynamic

I'm very new to SSIS, but have this week been completely burried in turorials of how to use it, this has been very fruitful so far but now I'm stuck with what seems a more complicated task.
I have two source SQl tables, which are dynamically created using the TSQL pivot function - so the numebr of columns in each will vary.
I feed a list of criteria into a for each loop whic his set to use an ADO enumerator to go through this data set and has a script task to set the string variable SQL_DOWNLOAD_STRING to point to one of the two poential tables using an IF statement. TABLEA or TABLEB.
I tried using the standard OLE DB source in the data flow, but the associated meta data was generated based on TABLEA at the time of build. I then set the SQL statement to be based on the variable SQL_DOWNLOAD_STRING and when I execute, the meta data of the source has changed as obviously it is a differnt table. That said even if itwas the same table there is no guarentee that the columns would be the same.
So my question is - how do I create the OLE DB Source dynamically so that it reconfigures to the new structure of the table?
Then I'm trying to export the data to an Excel workbook (which again I can do for a static source) but in this instance the mapping would need to change too & I imagine I'll need to rebuild the destination table to match the source from above.
If I can get a working example - then finishing the project should be pretty staright forward from there - examples for this sort of thing seem pretty limited though :(
Please help! (PS I'm working in VB)
Thanks

How to address the TableAdapter of a Dataset (made by wizard)

I created a new datasource with 4 tables of a sql database. In my first form i created a to_table_1 _bounded gridview via drag and drop. This created table Adapter and table adapter manager for example, which a bound to the form. Now I have a module1 where I want to perform an Insert Statement from the Table2Tableadapter. But I dont know how i can talk to the adapter, if I not create a gridview anywhere. I want to talk to the Datset.xsd table2 Adapter. Ther I already set up the sql Statements and the Insert statement is nevertheless Standard implemented in the adapter.
I know this must be so easy for someone who worked more then one time with databases. Hope You can help!
Cheers Steven
If you want to do your data access in a module then don't create the table adapter in the form; create it in the module. The Data Source wizard generates classes and you use those classes the same way you would any other. Do you have a problem using a String in a module? Of course not., If you want a String then you create a String. The same goes for a table adapter.
When you drag items onto a form from the Data Sources window it will generate some items automatically. There's no requirement that you keep all those items. Just delete the table adapter and manager and any code that uses them, then write your own code to populate a DataTable in your module. You've still got the DataSet in the form so you simply pass that, or a specific DataTable it contains, to your module to populate it.
You could go further and remove the DataSet from the form too and then use the GetData method of your table adapter to create a new DataTable and return that to the form. It's up to you. Don't limit yourself by what's generated for you. That is there to help but it's not the only way to do things. If you want to create something then create it.

Restrict SqlEntityConnection Type Provider to only certain tables

I am writing a utility for myself that needs to be able to access a pair of tables in a SQL database. I used the SqlEntityConnection Type Provider and was rewarded with the data I needed from the table as easy to use entities.
One thing I noticed though was that startup and compiling of the project increased by quite a lot. I suspect this is because the database has over a hundred tables and it's compiling and getting data from all of them as opposed to just the two I need. Is there a way to restrict the EntityTypeProvider to only referencing the needed tables in the schema?
type private EntityConnection = SqlEntityConnection<ConnectionString="Server=Server;Initial Catalog=Database;Integrated Security=SSPI;MultipleActiveResultSets=true", Pluralize = true>
let private context = EntityConnection.GetDataContext()
I have not tried this myself, but I think you could add a new "ADO.NET Entity Data Model" (edmx) file to your project, let it generate from your existing database, and then delete from the model every table you don't want accessible to your code.
The EDMX designer will generate a *.csdl file that you can then reference from the LocalSchemaFile parameter of SqlEntityConnection. You'd use this parameter instead of ConnectionString.
The end result is that the entity provider would not automatically pick up changes to your database, but compilation times will go down, and only the tables you care about would be visible to your code.

Get column names when you load from an access file

I load 10 tables from an ACCESS 2007 file database. IS their a way I can get the column names into the dataset or do I have to rename each column? I am using Visual Studio 2008 in VB.NET.
I would like to reference the columns in the code by the name and not have to use an index
I just went ahead and added the following code for each of the tables:
Table1.column(0).name = "NAME"
Table1.column(1).name = "ADDRESS"
Table1.column(2).name = "CITY"
Table1.column(3).name = "STATE"
But I do this for 10 tables so it can add up fast on the lines of code. But if their is a way for me to read it from the file I would like to replace all the lines of code with one line of code.
When you create the dataset, if you provide a connection string locally, when you generate the xsd file it should automatically type out any tables you add to the set. As long as you're using the tableadapters built into .Net, you can change the connection string of any tableadapter you use for your local config when you deploy.
When you right-click in the blank space of the new dataset you create (in the designer), you can add->tableadapter. It'll ask you for the connetion string to the database (provide it), and then you can submit a query. Start with the a general query for the basic table you're looking for. You can then add subsequent queries as you need them to the same table or create custom tables (and names) based on joins/other queries.
EDIT: I'm assuming some version of .Net is being used here.