473,589 Members | 2,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: send dataset as a parameter

Hello,
Can I send a dataset as a parameter into stored procedure and import data to
a table in the stored procedure?
Thanks,
Jim.

Nov 19 '05 #1
15 2236
I don't think a stored proc. would accept a DataSet because the SP is
running on your DB and the DB doesn't know what a DataSet is.
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:00******** *************** ***********@mic rosoft.com...
Hello,
Can I send a dataset as a parameter into stored procedure and import data
to
a table in the stored procedure?
Thanks,
Jim.

Nov 19 '05 #2
If you insist, you could have a text parameter in your stored
procedure. You could pass the xml as text, and in the SP use OPENXML to
intepret the text as xml. At that point, you can do xpath queries, etc.

Nov 19 '05 #3
You can absolutely pass text (in whatever form you like: plain text, html,
xml, etc.). But if you pass XML as a parameter to a SP, then you find
yourself in the same boat as if you passed a DataSet in terms of dealing
with the XML. Will the DB know what XPath is?

Can you do XPath queries on a DB?
"Wilco Bauwer" <wi****@gmail.c om> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com...
If you insist, you could have a text parameter in your stored
procedure. You could pass the xml as text, and in the SP use OPENXML to
intepret the text as xml. At that point, you can do xpath queries, etc.

Nov 19 '05 #4


Scott M. wrote:
You can absolutely pass text (in whatever form you like: plain text, html,
xml, etc.). But if you pass XML as a parameter to a SP, then you find
yourself in the same boat as if you passed a DataSet in terms of dealing
with the XML. Will the DB know what XPath is?
Yes, SQL Server 2000/2005 (also MSDE) can utilize both XPath and XML. I
believe that Oracle 9i and up can also handle XPath/XML. Other RDBMSs
that can: FireBird (1.3x and above), MySql(limited support in the 4.x.x
versions).

Can you do XPath queries on a DB?
"Wilco Bauwer" <wi****@gmail.c om> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com...
If you insist, you could have a text parameter in your stored
procedure. You could pass the xml as text, and in the SP use OPENXML to
intepret the text as xml. At that point, you can do xpath queries, etc.


Nov 19 '05 #5
Lookup OPENXML in the documentation of SQL server.

Nov 19 '05 #6
Thanks guys. I will try XML as last resort. I am wondering if I have a
dataset, which is basically a DataTable, couldn't I create a SQL table and
dump all the data from DataTable to this SQL table programmaticall y in
asp.net. I have some data in my dataset, I am trying to dump it to a table in
SQL Server.

"Scott M." wrote:
I don't think a stored proc. would accept a DataSet because the SP is
running on your DB and the DB doesn't know what a DataSet is.
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:00******** *************** ***********@mic rosoft.com...
Hello,
Can I send a dataset as a parameter into stored procedure and import data
to
a table in the stored procedure?
Thanks,
Jim.


Nov 19 '05 #7
Well, first understand that a DataSet is much more than just a DataTable.
Technically, a DataSet does not hold any data at all. It is just a
container to hold DataTables.

But the point of your question is, can you programmaticall y move the data
from a DataTable into a SQL table. Absolutely! There are several way to
accomplish this:

1. Use a .NET DataAdapter to populated the DataTable in the first place (or
to map the original table's structure to a .NET DataTable) and just call the
DataAdapter's Update method, which will move the DataTable data to the
source table.

2. Write a custom .NET Command (either SQL or SP) and call the
ExecuteNonQuery method of the Command to update the original table.

3. Serialize the data from the DataSet (via the GetXML method of the
DataSet) and either store the XML or parse the XML on the DB.
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:6A******** *************** ***********@mic rosoft.com...
Thanks guys. I will try XML as last resort. I am wondering if I have a
dataset, which is basically a DataTable, couldn't I create a SQL table and
dump all the data from DataTable to this SQL table programmaticall y in
asp.net. I have some data in my dataset, I am trying to dump it to a table
in
SQL Server.

"Scott M." wrote:
I don't think a stored proc. would accept a DataSet because the SP is
running on your DB and the DB doesn't know what a DataSet is.
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:00******** *************** ***********@mic rosoft.com...
> Hello,
> Can I send a dataset as a parameter into stored procedure and import
> data
> to
> a table in the stored procedure?
> Thanks,
> Jim.
>


Nov 19 '05 #8

Hello Scott,
First, thank you very mush for your great help. I had the following question
in the past, nobady replied. I have a proprietary database keeping table:
TableSrc: fname,lname,age In my asp.net application I am retrieving data
from TableSrc into a dataset: DataSet1 though an adapter. Now I created a SQL
Server table TableDest: Fname,Lname,Age and I want to append DataSet1 into
TableDest. How should I do this? Remember, DataSet1 is linked to TableSrc,
not TableDest. Are you suggesting me to create another adapter for TableDest
and use adapter.update( DataSet1), if yes, do you have any example for this, I
am quite new in asp.net.
Thanks,
Jim.
"Scott M." wrote:
Well, first understand that a DataSet is much more than just a DataTable.
Technically, a DataSet does not hold any data at all. It is just a
container to hold DataTables.

But the point of your question is, can you programmaticall y move the data
from a DataTable into a SQL table. Absolutely! There are several way to
accomplish this:

1. Use a .NET DataAdapter to populated the DataTable in the first place (or
to map the original table's structure to a .NET DataTable) and just call the
DataAdapter's Update method, which will move the DataTable data to the
source table.

2. Write a custom .NET Command (either SQL or SP) and call the
ExecuteNonQuery method of the Command to update the original table.

3. Serialize the data from the DataSet (via the GetXML method of the
DataSet) and either store the XML or parse the XML on the DB.
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:6A******** *************** ***********@mic rosoft.com...
Thanks guys. I will try XML as last resort. I am wondering if I have a
dataset, which is basically a DataTable, couldn't I create a SQL table and
dump all the data from DataTable to this SQL table programmaticall y in
asp.net. I have some data in my dataset, I am trying to dump it to a table
in
SQL Server.

"Scott M." wrote:
I don't think a stored proc. would accept a DataSet because the SP is
running on your DB and the DB doesn't know what a DataSet is.
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:00******** *************** ***********@mic rosoft.com...
> Hello,
> Can I send a dataset as a parameter into stored procedure and import
> data
> to
> a table in the stored procedure?
> Thanks,
> Jim.
>


Nov 19 '05 #9
Hi Jim,

Since you populated the dataset using a dataadapter that is linked to the
proprietary db and you want to take that data and append it to a different
db, you can't (as you probably know) use the same dataadapter that got you
the data in the first place.

So yes, you must create a different dataadapter that is linked to the SQL
Server table and pass the dataset data to this new dataadapter. It would go
something like this (VB.NET pseudo-code):

'Create the connection and dataadapter objects needed for SQL Server
Dim connectionStrin g As String = your connection string here or get from
Web.Config
Dim strSQL As String = "SELECT * FROM TableDest"
Dim sqlCon as New SqlClientConnec tion(connection String)
Dim sqlDA as New SqlClientDataAd apter(strSQL, sqlCon)

'Configure the dataadapter's UPDATE command to suit your needs
sqlDA.UpdateCom mand.CommandTex t = your update statement here

sqlDA.Update(Da taSet1)

Remember this is pseudo-code off the top of my head, so I might have missed
something, but this is the process you'll need to go through.

Good luck!
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:7A******** *************** ***********@mic rosoft.com...

Hello Scott,
First, thank you very mush for your great help. I had the following
question
in the past, nobady replied. I have a proprietary database keeping table:
TableSrc: fname,lname,age In my asp.net application I am retrieving data
from TableSrc into a dataset: DataSet1 though an adapter. Now I created a
SQL
Server table TableDest: Fname,Lname,Age and I want to append DataSet1 into
TableDest. How should I do this? Remember, DataSet1 is linked to TableSrc,
not TableDest. Are you suggesting me to create another adapter for
TableDest
and use adapter.update( DataSet1), if yes, do you have any example for
this, I
am quite new in asp.net.
Thanks,
Jim.
"Scott M." wrote:
Well, first understand that a DataSet is much more than just a DataTable.
Technically, a DataSet does not hold any data at all. It is just a
container to hold DataTables.

But the point of your question is, can you programmaticall y move the data
from a DataTable into a SQL table. Absolutely! There are several way
to
accomplish this:

1. Use a .NET DataAdapter to populated the DataTable in the first place
(or
to map the original table's structure to a .NET DataTable) and just call
the
DataAdapter's Update method, which will move the DataTable data to the
source table.

2. Write a custom .NET Command (either SQL or SP) and call the
ExecuteNonQuery method of the Command to update the original table.

3. Serialize the data from the DataSet (via the GetXML method of the
DataSet) and either store the XML or parse the XML on the DB.
"JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
news:6A******** *************** ***********@mic rosoft.com...
> Thanks guys. I will try XML as last resort. I am wondering if I have a
> dataset, which is basically a DataTable, couldn't I create a SQL table
> and
> dump all the data from DataTable to this SQL table programmaticall y in
> asp.net. I have some data in my dataset, I am trying to dump it to a
> table
> in
> SQL Server.
>
> "Scott M." wrote:
>
>> I don't think a stored proc. would accept a DataSet because the SP is
>> running on your DB and the DB doesn't know what a DataSet is.
>>
>>
>> "JIM.H." <JI**@discussio ns.microsoft.co m> wrote in message
>> news:00******** *************** ***********@mic rosoft.com...
>> > Hello,
>> > Can I send a dataset as a parameter into stored procedure and import
>> > data
>> > to
>> > a table in the stored procedure?
>> > Thanks,
>> > Jim.
>> >
>>
>>
>>


Nov 19 '05 #10

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

Similar topics

1
4922
by: a | last post by:
how to send an xml dataset to a Stored Procedure in mssql I have an xml file that I read into a dataset. and I'm trying to use a stored procedure (see SPROC #1 below) that inserts this xml dataset into an sql table via OpenXML. Nothing gets inserted into the sql table except nulls, so I think that perhaps I'm not actually sending the (xml) dataset to the SPROC. The code below fails on this line: sqlCommand1.ExecuteNonQuery();
4
2924
by: Michael Jones | last post by:
Ok.......... I'm trying to fill a parameterized table onto a Dataset via a sqlDataAdapter. It works fine if I fill the Dataset with all the column fields. What I want to do though is to only fill the Dataset with certain values from my DateTimeIn column (i.e. only files where DateTimeIn == user-defined date). This isn't working. I'm sure my query is correct because I've used the same code in different projects: SELECT...
1
7740
by: | last post by:
Hi, I've defined an ObjectDataSource and a parameterized DataSet. I would like it if I could pass the parameter value that describes the query that creates the DataSet as part of a user control declaration. Here's how the parameter is described in the context of my ObjectDataSource: <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetArticlesByWhomever" TypeName="WhateverTableAdapters.WhateverTableAdapter">
11
19850
by: scorpion53061 | last post by:
Well I had a way to write an array to an excel spreadsheet but on a huge time critical run it failed iwth the dreaded HRESULT: 0x800A03EC error. It worked fine when i sampled the data to go in but when it all tried to go in it bombed. So I need to write this to a tab delimited file and I sure hope somebody is awake tonight. How do I write my dataset to make a tab delimted text file?
3
3208
by: Gene Vangampelaere | last post by:
Hi, I'm having a frustrating problem :) I have an XML like this : <?xml version="1.0" encoding="utf-8"?> <cgb> <parameters> <parameter> <paramName>patientNr</paramName>
1
5538
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two other properties... bool error; string lastError; My whole class looks like this... using System;
2
1712
by: Alan Silver | last post by:
Hello, I have been trying the DataSet in VS2005, to see if it will simply some basic data access. So far it seems very useful, but I have run into a problem when trying to use a parameter for containstable (free text searching). If I enter a parameter in the containstable clause of a query... containstable(TaxTips, TipTitle, 'isabout (@kwords)')
6
2096
by: Ben | last post by:
Hi We have a Dataset that has been populated from the output parameter of a Stored Procedure (@Output). I understand that I can extract a single item when the dataset is populated by a table using this code: CType(objDataSet.Tables("MyTable").Rows(0).Item("MyField"), String)
3
3377
by: JJA | last post by:
I am confused about all the various methods of handling XML in ASP.Net 2.0. I want to be able to stream XML to some clientside Javascript code (snippet below): var urlRequest = "../GetLendersAsXML.aspx" var request = GXmlHttp.create(); request.open("GET", urlRequest, true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = request.responseXML;
0
7865
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
8233
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8360
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...
0
8224
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
5399
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
3849
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...
1
2374
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
1
1461
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1198
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.