Creating Datasets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I wanted to ask a question regarding how i could create a dataset using the the wizard. This is what i have done so far..
1) i have right clicked in the solution explorer in vb.net and selected 'add new item
2) i selected a 'dataset
3) i drag the tables that i require from the server explorer

the question i have is that how do i create a datatable that does not match a table that is currently in my database (server explorer)

i.e if i have 3 tables in my database
Table1 Table2 Table
att1 att4 att
att2 att5 att
att3 att6 att1
att

i want to display table1 exactly how it is so i drag it from my server explorer
I then want my second datatable to be made up of att4, att5, att6, att10
the last table i want all the attributes from table3 and then 2 additional attribute that are just made up. i.e sum of att8 and att9

Can anyone tell me how i would create the last 2 datatables shown above
I know how to do this via code (i just write the appropriate select query and join the relevant tables) but i want to be able to do this via the wizard

thx in advance.
 
Hi,

Drop a DataAdapter on your form and follow the wizard's instructions.
(You will have to enter a sql select statament)

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Bhavna said:
Hi,

I wanted to ask a question regarding how i could create a dataset using
the the wizard. This is what i have done so far...
1) i have right clicked in the solution explorer in vb.net and selected 'add new item'
2) i selected a 'dataset'
3) i drag the tables that i require from the server explorer.

the question i have is that how do i create a datatable that does not
match a table that is currently in my database (server explorer)?
i.e if i have 3 tables in my database.
Table1 Table2 Table3
att1 att4 att8
att2 att5 att9
att3 att6 att10
att7

i want to display table1 exactly how it is so i drag it from my server explorer.
I then want my second datatable to be made up of att4, att5, att6, att10.
the last table i want all the attributes from table3 and then 2 additional
attribute that are just made up. i.e sum of att8 and att9.
Can anyone tell me how i would create the last 2 datatables shown above?
I know how to do this via code (i just write the appropriate select query
and join the relevant tables) but i want to be able to do this via the
wizard.
 
Hi Miha

I am getting an error using this method
Let me explain what i have done in the hope that u can see my errors
I had it working initially using code to create the dataset, datatables and datarelations on the form_load event. I was able to insert into the various datatable with no problem then
What i have now done is to comment out this code and clicked 'add new item' and then i added a dataset. I named it the same to my one i had working when i used the code (dsFullBooking)
I then dragged 2 tables from the server explorer onto the pane and then set the relationship between the 2 tables to the name i called it previously (when done via code)
I then used your method to create the tables i.e i dragged a dataadapter onto my form and used an sql query to create a datatable. once I finished this i right clicked on my dataadapter and selected generate dataset. I checked the 'existing dataset' radio button and chose the dataset i the first 2 tables are in (dsFullBooking). I used the same dataadapter to repeat the process for all the other tables
Once i had finished creating all the datatables, i opened the dsFullBooking.xsd file and created the relationships between all the tables. I ensured that i named them the same as when i created it via code

On the form i wrote code to fillschema on all the datatables in my dataset (dsFullBooking
The problem i am having is that when i run the application i can insert into the first 2 tables ok. (i.e the tables that i simpl dragged into the dataset (dsFullBooking) from the server explorer. However when i try to insert into any of the other datatables it does not work!
When i try to insert into one of the datatables that are generated via the sql query, i get the following error..

An unhandled exception of type 'System.Data.NoNullAllowedException' occurred in system.data.dl

Additional information: Column 'ClientID' does not allow nulls

The problem is that this table does not even contain this column.

Do u have any idea what i may be doin wrong
If anyone can help me i would really apprecaite it
Thx
 
Hi Bhavna,

It is a bit difficult to see from here.
Question: do you invoke FillSchema on tables that you've created at design
time?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Bhavna said:
Hi Miha,

I am getting an error using this method.
Let me explain what i have done in the hope that u can see my errors.
I had it working initially using code to create the dataset, datatables
and datarelations on the form_load event. I was able to insert into the
various datatable with no problem then.
What i have now done is to comment out this code and clicked 'add new
item' and then i added a dataset. I named it the same to my one i had
working when i used the code (dsFullBooking).
I then dragged 2 tables from the server explorer onto the pane and then
set the relationship between the 2 tables to the name i called it previously
(when done via code).
I then used your method to create the tables i.e i dragged a dataadapter
onto my form and used an sql query to create a datatable. once I finished
this i right clicked on my dataadapter and selected generate dataset. I
checked the 'existing dataset' radio button and chose the dataset i the
first 2 tables are in (dsFullBooking). I used the same dataadapter to repeat
the process for all the other tables.
Once i had finished creating all the datatables, i opened the
dsFullBooking.xsd file and created the relationships between all the tables.
I ensured that i named them the same as when i created it via code.
On the form i wrote code to fillschema on all the datatables in my dataset (dsFullBooking)
The problem i am having is that when i run the application i can insert
into the first 2 tables ok. (i.e the tables that i simpl dragged into the
dataset (dsFullBooking) from the server explorer. However when i try to
insert into any of the other datatables it does not work!!
When i try to insert into one of the datatables that are generated via the
sql query, i get the following error...
 
Hi Miha

Iinvioke fillSchema at runtime. It is on a form load_event. I had no idea i could do this at design time
 
Back
Top