Could not add an instance of <dataset> to the designer

A

Axel

Hi there,
I'm running visual studio.net 2003, I am new to the software, so pls
be gentle.
I trying to add a typed dataset to a webform.aspx however every time I
am getting "Could not add an instance of <dataset> to the designer. To
resolve this problem, build the project, fix any errors, and add the
instance to the designer again." error. I've tried building the
solution (there were no errors)saving it and then trying to add the
dataset, as suggested in the help... but still no joy. I am getting
really annoyed with it. could somebody pls help me.

thanks in advace
Axel
 
S

Scott M.

You need to tell us exactly what you have done in order for us to be able to
give you possible solutions.
 
A

Axel Huensche

Hi there, thanks for reply, Iwas following the walkthrough from the Help
in Visual Studio .... see below

You are also going to add a component where you create the data-access
object that contains your data source.

To create the Web Form

On the File menu, click New, and then click Project.
The New Project dialog box appears.

In the Project Type pane, click Visual Basic Projects or Visual C#
Projects, and in the Templates pane, select ASP.NET Web Application.
Name your application MyWebForm by changing the default name in the
Location box (such as http://localhost/WebApplication1 to
http://localhost/MyWebForm.
Click OK.
The application wizard will create the necessary project files,
including the following files:

WebForm1.aspx - Contains the visual representation of the Web Form.
WebForm1.aspx.cs or WebForm1.aspx.vb – The code-behind file that
contains the code for event handling and other programmatic tasks. To
see this file in Solution Explorer, click the Show All Files icon, and
then expand the WebForm1.aspx node.
Web Form Files



Note If Solution Explorer is not open, on the View menu, click
Solution Explorer.

For more details on creating a Web Application project, see Creating Web
Projects. For information on configuring the security settings of your
project, see Using SQL Server in Web Applications.

To add the component

In Solution Explorer, right-click the project name.
On the shortcut menu, click Add, and then click Add Component.
The Add New Item dialog box appears and the Component Class in the right
pane will be selected by default.

Accept the default name (Component1) and click Open.
Unless you choose another name for the component, this creates a new
file in your project named Component1.cs or Component1.vb depending on
the application language. The Component Designer opens a design view on
Component1.cs or Component1.vb.

Creating the Data-Access Component
A dataset can be used to bind data values into the HTML transmitted to
the client. It can be created either on the Web Form itself or on the
component. To simulate real-life situations, you will create it on the
component. You will also write the necessary code to fill the dataset
with data from the database.

To add and configure a data source

On the View menu, click Toolbox.
From the Data tab of the Toolbox, drag sqlDataAdapter onto the Component
Designer surface.
The DataAdapter Configuration Wizard appears.

Click Next to advance to the Choose Your Data Connection page, and then
click New Connection.
The Data Link Properties dialog box appears.

In the Connection tab of the Data Link Properties dialog box:
Enter the name of the server where the pubs database is installed.
Enter the logon information for the server.
Select pubs from the database list.
Test the data link by clicking the Test Connection button.
Click OK to return to the wizard.
The name of the data connection appears in the drop-down list.

Note If you do not know the user name and password for the SQL Server
pubs database, contact your database administrator.

Data Link Properties



Click Next to advance to the Choose a Query Type page.
Select Use SQL statements, and then click Next.
In the Generate the SQL Statements page, click Query Builder.
In the Tables tab of the Add Table dialog box, click titles, click Add,
and then click Close.
This adds the titles table to your SQL query.

In the Query Builder dialog box, shown in the following figure, select
the title_id, title, price, notes, and pubdate check boxes, and then
click OK to generate the SQL statement and return to the DataAdapter
Configuration Wizard.
Query Builder



The Generate the SQL Statements page displays the generated SQL
statement.

Click Finish to exit the DataAdapter Configuration Wizard and connect
your data source to the titles table. The following objects are added to
the Component Designer surface:
sqlDataAdapter1
sqlConnection1
Alternately, you can create both the sqlDataAdapter1 and sqlConnection1
objects by using Server Explorer. To do that, expand the SQL Servers
tree to display your server, the pubs database, and the titles table as
shown in the following figure. Expand titles and select the required
columns, and then drag them onto the Component Designer surface.

Server Explorer



You can view the generated code in the InitializeComponent method of the
file Component1.cs (or the InitializeComponent subroutine of the file
Component1.vb). To do that, switch to the code view by right-clicking
Component1.cs (or Component1.vb) in Solution Explorer, and then click
View Code from the shortcut menu.

Save the project by clicking Save All on the File menu.
To generate and fill the dataset

If the Component Designer is not visible, double-click the file
Component1.cs (or Component1.vb) in Solution Explorer.
From the Data menu, click Generate DataSet.
The Generate DataSet dialog box appears.

If it is not already selected, select the New radio button. In the
corresponding text box, enter a name such as myDataSet.
Make sure that the Add this dataset to the designer check box is not
selected, and click OK.
The file myDataSet.xsd appears in Solution Explorer.

You can view the XML schema and code that describe myDataSet by
double-clicking myDataSet.xsd in Solution Explorer. Note that the
DataSet and XML tabs are located at the lower left corner of the XML
Designer surface.

Dataset Schema



Binding the DataGrid
In this section, you add a dataset to the Web Forms page, fill it with
data, and bind it to the DataGrid.

To add a dataset to the form

In Solution Explorer, double-click the WebForm1.aspx file to select the
Web Forms page.
On the View menu, click Toolbox.
Drag a DataSet from the Data tab of the Toolbox onto the Web Forms
Designer surface.
The Add DataSet dialog box appears.

If it is not already selected, select TypedDataSet.
Select the name of the dataset (MyWebForm.myDataSet) from the drop-down
list and click OK.
This adds a dataset, myDataSet1, to the nonvisual part of the Web Forms
Designer surface.

---- At this stage I get the error I mentioned earlier, hope this makes
a bit clear
many thanks in advance

Axel
 
J

John Saunders

Axel, you're not alone :-(

Axel Huensche said:
Hi there, thanks for reply, Iwas following the walkthrough from the Help
in Visual Studio .... see below
....
To add a dataset to the form

In Solution Explorer, double-click the WebForm1.aspx file to select the
Web Forms page.
On the View menu, click Toolbox.
Drag a DataSet from the Data tab of the Toolbox onto the Web Forms
Designer surface.
The Add DataSet dialog box appears.

If it is not already selected, select TypedDataSet.
Select the name of the dataset (MyWebForm.myDataSet) from the drop-down
list and click OK.
This adds a dataset, myDataSet1, to the nonvisual part of the Web Forms
Designer surface.

---- At this stage I get the error I mentioned earlier, hope this makes
a bit clear
many thanks in advance

I just got this error when trying to drag a DataSet onto a Web Form. The
Typed DataSet was part of another project in the same solution. This second
project _is_ referenced by the first (web) project. This is proven by the
fact that I can declare a variable of the type of this DataSet!

But the designer doesn't like it. I'd sure like to be able to reference a
typed dataset from another project in the solution, so that I don't have to
duplicate the .xsd file in every project that references it!

If anyone has any idea, please let me know ASAP, as this code is due Monday.

John Saunders
 

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