472,119 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

how to insert record from another table to dataset?

as of now i am using a stored procedure from my sql server 2000 to
insert record from another table. what i need now is on how can i
insert record by not using the stored procedure and insert it using
dataset.

here is my code in stored procedure..

CREATE PROCEDURE AddRegularLoad

@SchYrSemID as int, @ProgramID as int, @Sem as varchar(50), @Year as
int

AS

BEGIN

SET NOCOUNT OFF

INSERT INTO SchYrSemCourseJoin ( CourseID, SchYrSemID )
SELECT CourseID, @SchYrSemID
FROM RegularLoad INNER JOIN [RegularLoad Details] ON
RegularLoad.RegularLoadID = [RegularLoad Details].RegularLoadID
WHERE ProgramID=@ProgramID AND Year=@Year AND Semester=@Sem;

END
GO

Nov 20 '05 #1
10 2496
"jaYPee" <hi******@yahoo.com> schrieb
as of now i am using a stored procedure from my sql server 2000 to
insert record from another table. what i need now is on how can i
insert record by not using the stored procedure and insert it
using dataset.
[...]
INSERT INTO SchYrSemCourseJoin ( CourseID, SchYrSemID )
SELECT CourseID, @SchYrSemID
FROM RegularLoad INNER JOIN [RegularLoad Details] ON
RegularLoad.RegularLoadID = [RegularLoad Details].RegularLoadID
WHERE ProgramID=@ProgramID AND Year=@Year AND Semester=@Sem;


IMO, a dataset doesn't make sense here. You don't want to load data into
memory, and that's where the dataset is used for. I think the SP is already
the best solution.
More ADO.Net: microsoft.public.dotnet.framework.adonet

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
"Armin Zingler" <az*******@freenet.de> schrieb
into memory, and that's where the dataset is used for. I think the SP


...what the dataset is used for..
--
Armin

Nov 20 '05 #3
don't know wat u mean...this dataset is used to stored the data from
my table from my sql server 2000. am i right?
On Fri, 23 Apr 2004 10:14:12 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
"Armin Zingler" <az*******@freenet.de> schrieb
into memory, and that's where the dataset is used for. I think the SP


..what the dataset is used for..


Nov 20 '05 #4
"jaYPee" <hi******@yahoo.com> schrieb
don't know wat u mean...this dataset is used to stored the data
from my table from my sql server 2000. am i right?

I also don't know what you mean. The query copies records from one table to
the other. This is done on the server. I don't see why you need a dataset.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
because when i used stored procedure it is automatically save the data
to another table. while if i don't used the stored procedure i have
the option if i want to save the data or not. by the way this data
will be inserted to the datagrid in my form

On Fri, 23 Apr 2004 11:44:23 +0200, "Armin Zingler"
<az*******@freenet.de> wrote:
"jaYPee" <hi******@yahoo.com> schrieb
don't know wat u mean...this dataset is used to stored the data
from my table from my sql server 2000. am i right?

I also don't know what you mean. The query copies records from one table to
the other. This is done on the server. I don't see why you need a dataset.


Nov 20 '05 #6
"jaYPee" <hi******@yahoo.com> schrieb
because when i used stored procedure it is automatically save the
data to another table. while if i don't used the stored procedure i
have the option if i want to save the data or not. by the way this
data will be inserted to the datagrid in my form


You did not mention what's your intention. Makes it hard to understand.

Yes, you can load the data in a dataset and bind it to a datagrid. Later you
can store the changes to the database. I'm not sure what's exactly your
problem. Here's the entry for using Datasets and data binding:

http://msdn.microsoft.com/library/en...ngdatasets.asp
http://msdn.microsoft.com/library/en...riDatasets.asp
http://msdn.microsoft.com/library/en...chitecture.asp

See also the already mentioned ADO.Net group for ADO.Net specific questions.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #7
Hi jaYpee,

To give you Microsoft samples is difficult as I said because they all go not
farther than the fill, you seldom see them complete with the update.

Try to find this things
You need a connection (which you have already)
A dataadapter
A dataset.

The dataadapter is a class which does a lot for you.

When you use with that the
commandbuilder, than you are for the start very happy.

What you do
You make the connection.
You fill your dataset using the dataadapter
You bind that to your dagagrid (I asume all is windows forms)

The changes are done and you do
currencymanager.endcurrentedit (this is not the complete code)

Than you look if the dataset has changes
if dataset.haschanges
dataadapter.update(dataset)
end if

And all this you use in try and catch blocks.

Than your data handling is almost done.

I hope this helps someting?

Cor
Nov 20 '05 #8
Hi I forgot to say if you have more detailed questions feel free to ask?

Cor
Nov 20 '05 #9
my purpose is this. i have 2 datagrid in my form. the 2nd datagrid is
related to the 1st datagrid. now in my 1st datagrid there is a
checkbox that when i click that i want to fill the 2nd datagrid w/
records from another table. i have successfully done this in ms-access
and don't know how to do this w/ vb.net

anyway here's the code i used in ms-access when the value of checkbox
is equals to true.

DoCmd.RunSQL "INSERT INTO SchYrSemCourseJoin (
CourseID, SchYrSemID ) " _
& "SELECT [RegularLoad Details].CourseID, " &
Me!SchYrSemID & " " _
& "FROM RegularLoad INNER JOIN [RegularLoad
Details] " _
& "ON RegularLoad.RegularLoadID = [RegularLoad
Details].RegularLoadID " _
& "WHERE (((RegularLoad.ProgramID)= " &
Forms![Students]![ProgramID] & ") AND (RegularLoad.MajorID= " &
Me!MajorID & ") AND ((RegularLoad.Year)= " & Me!Year & ") AND " _
& "((RegularLoad.Semester)= '" & Me!Sem & "'));"

the table regular load and regular load details is related to each
other and is act as a template to the table schyrsemcoursejoin.

pls tell me if i did not explain better.

thanks for the help

On Fri, 23 Apr 2004 14:45:07 +0200, "Cor Ligthert"
<no**********@planet.nl> wrote:
Hi I forgot to say if you have more detailed questions feel free to ask?

Cor


Nov 20 '05 #10
Hi jaYPee,

There are two methods (It is not standard) for using a combobox in a
datagrid.

The one is with a combobox and the otherone is with a comboboxcolumn, which
one are you using?

Although it is again a long time ago that I did look at that, so my help
will be probably very fair.

Cor
Nov 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Yog | last post: by
3 posts views Thread by Steven Stewart | last post: by
1 post views Thread by Abareblue | last post: by
reply views Thread by Eustice Scrubb | last post: by
3 posts views Thread by RN1 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.