How to fill DataSet from stored procedure? 9 47204
It goes a bit like this . . .
Dim cmd As New OleDb.OleDbComm and
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = "MyStoredProced ure"
cmd.Connection = MyConnection
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Nikolay Petrov" <jo******@mail. bg> wrote in message
news:eA******** ******@TK2MSFTN GP09.phx.gbl... How to fill DataSet from stored procedure?
I know this, but how actually to read the data returned by the stored
procedure and put it in the dataset?
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. . It goes a bit like this . . .
Dim cmd As New OleDb.OleDbComm and
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = "MyStoredProced ure"
cmd.Connection = MyConnection
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Nikolay Petrov" <jo******@mail. bg> wrote in message news:eA******** ******@TK2MSFTN GP09.phx.gbl... How to fill DataSet from stored procedure?
I assume you are using MS SQL Server.
-- Code Start --
Dim sqlCon As New SqlConnection (<connection string>)
Dim sqlAdp As New SqlDataAdapter
Dim sqlCmd As New SqlCommand
Dim ds As New DataSet
sqlCmd.Connecti on = sqlCon
sqlCmd.CommandT ext = <sp name>
sqlCmd.CommandT ype = CommandType.Sto redProcedure
' Add any parameters to the stored proc here using sqlCmd.Paramete rs
collection
sqlAdp.SelectCo mmand = sqlCmd
sqlAdp.Fill (ds)
-- Code End --
"Nikolay Petrov" <jo******@mail. bg> wrote in message
news:eA******** ******@TK2MSFTN GP09.phx.gbl...
How to fill DataSet from stored procedure?
"Nikolay Petrov" <jo******@mail. bg> wrote in message
news:eA******** ******@TK2MSFTN GP09.phx.gbl... How to fill DataSet from stored procedure?
Create a xxxCommand object around the stored procedure and then use that
object when creating the xxxDataAdapter.
Air code:
Dim cnn As SqlConnection = New SqlConnection(" Data Source=MySrv;In itial
Catalog=MyDB;In tegrated Security=SSPI")
cnn.Open()
Dim cmd As SqlCommand = New SqlCommand("MyS P", cnn)
cmd.CommandType = CommandType.Sto redProcedure
Dim da As SqlDataAdapter = New SqlDataAdapter( cmd)
Dim ds As DataSet
da.Fill(ds, "MyTable")
Try this.....
' Open db connection
Dim cnn As New SqlConnection(C ONNECTION_STRIN G)
cnn.Open()
' Set command for the stored procedure
Dim cmd As New SqlCommand
With cmd
..CommandType = CommandType.Sto redProcedure
..Connection = cnn
..CommandText = "CustOrderH ist"
..Parameters.Ad d("@CustomerID" , "ALFKI")
End With
' Create data adapter
Dim da As New SqlDataAdapter( cmd)
' Fill dataset from adapter
Dim ds As New DataSet
da.Fill(ds)
Hope this helps.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. . It goes a bit like this . . .
Dim cmd As New OleDb.OleDbComm and
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = "MyStoredProced ure"
cmd.Connection = MyConnection
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Nikolay Petrov" <jo******@mail. bg> wrote in message news:eA******** ******@TK2MSFTN GP09.phx.gbl... How to fill DataSet from stored procedure?
Maybe my question was wrong.
I needed to know does any data will be returned from stored procedure select
statment to dataset.
I mean when the sqlcommand.comm andType is text and .CommandText is the SQL
statemen everything works ok, but when the same sql statment is in stored
procedure does the DataSet iss filled properly?
"Jeff Johnson [MVP: VB]" <i.***@enough.s pam> wrote in message
news:O4******** *****@TK2MSFTNG P12.phx.gbl... "Nikolay Petrov" <jo******@mail. bg> wrote in message news:eA******** ******@TK2MSFTN GP09.phx.gbl...
How to fill DataSet from stored procedure?
Create a xxxCommand object around the stored procedure and then use that object when creating the xxxDataAdapter.
Air code:
Dim cnn As SqlConnection = New SqlConnection(" Data Source=MySrv;In itial Catalog=MyDB;In tegrated Security=SSPI") cnn.Open() Dim cmd As SqlCommand = New SqlCommand("MyS P", cnn) cmd.CommandType = CommandType.Sto redProcedure Dim da As SqlDataAdapter = New SqlDataAdapter( cmd) Dim ds As DataSet
da.Fill(ds, "MyTable")
Whatever the stored procedure returns will be populated in the dataset -
exactly the same as if the commandType is Text and a SQL statement is
provided. Make sure the stored procedure you are using is returning what
you are expecting in query analyser or similar then use the code posted
previously - it should work.
Hope this helps.
"Nikolay Petrov" <jo******@mail. bg> wrote in message
news:O7******** ******@TK2MSFTN GP10.phx.gbl... Maybe my question was wrong. I needed to know does any data will be returned from stored procedure
select statment to dataset. I mean when the sqlcommand.comm andType is text and .CommandText is the SQL statemen everything works ok, but when the same sql statment is in stored procedure does the DataSet iss filled properly?
"Jeff Johnson [MVP: VB]" <i.***@enough.s pam> wrote in message news:O4******** *****@TK2MSFTNG P12.phx.gbl... "Nikolay Petrov" <jo******@mail. bg> wrote in message news:eA******** ******@TK2MSFTN GP09.phx.gbl...
How to fill DataSet from stored procedure?
Create a xxxCommand object around the stored procedure and then use that object when creating the xxxDataAdapter.
Air code:
Dim cnn As SqlConnection = New SqlConnection(" Data Source=MySrv;In itial Catalog=MyDB;In tegrated Security=SSPI") cnn.Open() Dim cmd As SqlCommand = New SqlCommand("MyS P", cnn) cmd.CommandType = CommandType.Sto redProcedure Dim da As SqlDataAdapter = New SqlDataAdapter( cmd) Dim ds As DataSet
da.Fill(ds, "MyTable")
Thank you all guys
"Jeff Johnson [MVP: VB]" <i.***@enough.s pam> wrote in message
news:O4******** *****@TK2MSFTNG P12.phx.gbl... "Nikolay Petrov" <jo******@mail. bg> wrote in message news:eA******** ******@TK2MSFTN GP09.phx.gbl...
How to fill DataSet from stored procedure?
Create a xxxCommand object around the stored procedure and then use that object when creating the xxxDataAdapter.
Air code:
Dim cnn As SqlConnection = New SqlConnection(" Data Source=MySrv;In itial Catalog=MyDB;In tegrated Security=SSPI") cnn.Open() Dim cmd As SqlCommand = New SqlCommand("MyS P", cnn) cmd.CommandType = CommandType.Sto redProcedure Dim da As SqlDataAdapter = New SqlDataAdapter( cmd) Dim ds As DataSet
da.Fill(ds, "MyTable")
"Nikolay Petrov" <jo******@mail. bg> wrote in message
news:O7******** ******@TK2MSFTN GP10.phx.gbl... Maybe my question was wrong. I needed to know does any data will be returned from stored procedure
select statment to dataset. I mean when the sqlcommand.comm andType is text and .CommandText is the SQL statemen everything works ok, but when the same sql statment is in stored procedure does the DataSet iss filled properly?
Yes, IF the stored procedure returns a resultset. If it's a stored procedure
that only sends back a return value and/or fills output parameters then it
won't fill the DataSet, but then you wouldn't choose such a stored procedure
in the first place, would you? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Wayde |
last post by:
Please help me if you know the answer to this. I want to
create a dataAdapter, that fills a dataSet. However, I
have a stored procedure that I want to use, that takes one
int as input. I have been trying this for a few hours now,
and have come no closer.
|
by: gh |
last post by:
I have made the following stored procedure with the following select
statement
select * from user
select * from order, orderdetail where order.id=orderdetail.id
I know I can uses DataReader class to get data from the store procedue.
However, is there any way for me to use DataAdapter to get the data and put
it in separate DataTables in a DataSet?
|
by: Mike P |
last post by:
Is it possible to return a dataset from a stored procedure, or would you
need to write the SQL in your .cs file to return the dataset?
Any assistance would be really appreciated.
Cheers,
Mike
|
by: Dino L. |
last post by:
How can I run stored procedure (MSSQL) ?
|
by: Viktor Popov |
last post by:
Hi,
I would like to ask you do you know how to return a resultset and int value
from Stored Procedure.
If we have a table
Teachers
=========
ID INT PK
NAME VARCHAR(25)
ADDR VARCHAR(75)
| |
by: Telemaco |
last post by:
Ho la necessità di inserire i risultati di una stored procedure in un
dataset.
Mi spiego meglio ....
Ho costruito una store procedure che incapsula una query di lettura su un
database sqlserver che restituisce di dati in formato xml.
La clausola utilizzata per avere il risultato in xml è: FOR XML
AUTO,XMLDATA, e la stored procedure si chiama SP_Lettura ed accetta tre
parametri interi P1,P2,P3.
....
|
by: joun |
last post by:
Hi all, i'm using this code to insert records into an Access table from
asp.net, using a
stored procedure, called qry_InsertData:
PARAMETERS Long, Long, Text(20), Long,
DateTime;
INSERT INTO Table ( ID, Cod, CodArt, Q1, DataUscita )
VALUES (pID, pCod, pCod, pQ1, pDataUscita);
|
by: Rich |
last post by:
I have a stored procedure on Sql Server2k. I can fill a data table which I
can append to a dataset using an ADODB recordset object which gets populated
from a command object that runs the sp. I was hoping to use a DataAdapter.
But I think the data adapter only uses select statements. I could write the
sp in my vb.net app, but the sp references UDF's I wrote in the Sql Sever. I
will guess that I will need to stick with the ADODB recordset...
|
by: dawson |
last post by:
Hello, from the code below, how do I add/send a parameter to the stored
procedure?
SqlConnection conn = null;
conn = new
SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings.ConnectionString);
conn.Open();
SqlDataAdapter daProjects = new SqlDataAdapter("dbo.getProjectFiles",
conn);
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |