473,685 Members | 2,906 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 SchYrSemCourseJ oin ( CourseID, SchYrSemID )
SELECT CourseID, @SchYrSemID
FROM RegularLoad INNER JOIN [RegularLoad Details] ON
RegularLoad.Reg ularLoadID = [RegularLoad Details].RegularLoadID
WHERE ProgramID=@Prog ramID AND Year=@Year AND Semester=@Sem;

END
GO

Nov 20 '05 #1
10 2630
"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 SchYrSemCourseJ oin ( CourseID, SchYrSemID )
SELECT CourseID, @SchYrSemID
FROM RegularLoad INNER JOIN [RegularLoad Details] ON
RegularLoad.Reg ularLoadID = [RegularLoad Details].RegularLoadID
WHERE ProgramID=@Prog ramID 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.publi c.dotnet.framew ork.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*******@free net.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*******@free net.de> wrote:
"Armin Zingler" <az*******@free net.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*******@free net.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.haschan ges
dataadapter.upd ate(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 SchYrSemCourseJ oin (
CourseID, SchYrSemID ) " _
& "SELECT [RegularLoad Details].CourseID, " &
Me!SchYrSemID & " " _
& "FROM RegularLoad INNER JOIN [RegularLoad
Details] " _
& "ON RegularLoad.Reg ularLoadID = [RegularLoad
Details].RegularLoadID " _
& "WHERE (((RegularLoad. ProgramID)= " &
Forms![Students]![ProgramID] & ") AND (RegularLoad.Ma jorID= " &
Me!MajorID & ") AND ((RegularLoad.Y ear)= " & 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 schyrsemcoursej oin.

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**********@p lanet.nl> wrote:
Hi I forgot to say if you have more detailed questions feel free to ask?

Cor


Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2240
by: Yog | last post by:
I have a datagrid binded to a dataset and once the user updates the grid my dataset is reflected. When i wanted to save the data to tables, however i needed to insert this data into another table instead of the same table. I am getting the error in the line oDa.Update(oDs.Tables.Select("", "", DataViewRowState.CurrentRows)); "Update requires a valid UpdateCommand when passed DataRow collection with
3
3576
by: Steven Stewart | last post by:
Hi there, I have posted about this before, but yet to arrive at a solution. I am going to try to explain this better. I have an Employees table and a Datarecords table (one-to-many relationship). I have fields called InventoryOut and BalanceEnd that are calculated on the fly for reports and when displayed on forms (they are not part of any table). I have another field called "BalCarFor" (Balance Carried Forward) that is part of the...
8
6288
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with one-to-one relationship but on this occasion I must keep username/password details within a seperate table. Here's the basic specs and database schema: -------------------------------------------
1
2920
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
4
11832
by: authorking | last post by:
I use the following code to insert a data record in to a datatable of an access database.But every time I execute the command, there will rise an exception and the insert operation can't be completed. here's the code: System.Data.OleDb.OleDbConnection hist_cnn = new System.Data.OleDb.OleDbConnection(); System.Data.OleDb.OleDbCommand hist_command = new System.Data.OleDb.OleDbCommand();
4
2198
by: Mike Hnatt | last post by:
My goal is to get data from an XML file into a couple of tables in an Access database. The XML file is a little complex so I need control over what I do (I can't just read it into a dataset). The way I have it now is ennumerating through my XML file and for each record, running an INSERT INTO SQL statement to put the values in the database. Is this going to be okay with 50 or so records (hitting the database with 50 or so INSERT...
0
1524
by: Eustice Scrubb | last post by:
In line coding problem. Here's my code: <script language="VB" runat="server"> Dim myConnection As SqlConnection Sub Page_Load(Src As Object, e As EventArgs) ' Create a connection to the SQL Server myConnection = New SqlConnection("Data Source=SERVER;" _ & "Initial Catalog=database;User Id=user;Password=password;")
13
2449
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever works best) to display a dropdown menu of fields populated from table tblInvoiceData. This control also includes a textbox which the user can input a value. These two columns are side by side and not in a vertical layout. The user then clicks on...
3
1411
by: RN1 | last post by:
This is how I am trying to insert a new record in a database table & then display all the records (including the newly inserted record) in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) Dim dSet As DataSet Dim dTable As DataTable Dim sqlCmd As SqlCommand Dim sqlConn As SqlConnection
0
8507
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8926
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8761
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7589
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4302
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2938
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.