473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Can You Run a Stored Procedure Using SQLDataAdapter?

Hi.

Is it possible to run a Stored Procedure that takes 1 parameter using the
SQLDataAdapter. I'm currently using the SQLCommand with the SQLDataReader to
do this but would like to use a disconnected recordset.

Maybe a way to do this is to use the SQLCommand and then set a DataTable to
the
SQLDataReader. I played around with this approach for awhile but could not
get it to work.

Any suggestions will be greatly appreciated!

Rita
Jul 21 '05 #1
2 1374
Could be like this

SqlCommand1.CommandText = "spRetrievenfo";
SqlCommand1.CommandType = CommandType.StoredProcedure;
SqlCommand1.Connection = myConnection;
SqlCommand1Parqameters.Add(/////your parameters)

private void DataAdapterWithStoredProcedure()
{
DataSet ds = new DataSet();
//Assume da is your DataAdapter
da.SelectCommand = SqlCommand1;
da.SelectCommand.Parameters.[0].Value = "YourValue";
da.Fill(ds);
}

Hope this Helps
Jul 21 '05 #2
Thanks so much! It worked perfectly.

"SerhaD Ýnanlý" wrote:
Could be like this

SqlCommand1.CommandText = "spRetrieveÝnfo";
SqlCommand1.CommandType = CommandType.StoredProcedure;
SqlCommand1.Connection = myConnection;
SqlCommand1Parqameters.Add(/////your parameters)

private void DataAdapterWithStoredProcedure()
{
DataSet ds = new DataSet();
//Assume da is your DataAdapter
da.SelectCommand = SqlCommand1;
da.SelectCommand.Parameters.[0].Value = "YourValue";
da.Fill(ds);
}

Hope this Helps

Jul 21 '05 #3

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

Similar topics

3
by: Oldhandandy | last post by:
I have a SQL stored procedure that I need to run by pressing a button on a .Net form. I've created a SQLConnection, the form and a button, what code do I need to run the procedure.
4
by: Mullin Yu | last post by:
i have a stored procedure at sql server 2k. which will update records and select result from temp table. if i use SqlConnection class, and i do both. but, if i use OleDbConnection class, i can...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
2
by: Mike Hutton | last post by:
I have a rather odd problem. I have a SP which uses temp. tables along the way, and then returns a table of results: CREATE PROCEDURE dbo.usp_myproc( @pNameList VARCHAR(6000) ) AS
1
by: hlam | last post by:
I am configuring an SqlDataAdapter using a stored procedure (which uses UNIONS and a Temporary Table) in Visual Studio.Net My stored procedure consists of: SELECT ... INTO #tbltemporary ...
9
by: Nikolay Petrov | last post by:
How to fill DataSet from stored procedure?
2
by: Roy | last post by:
Hey all, Here's a small VB codeblock that connects to a database and uses 2 SQL queries then forms a relation for a master/detail view on the aspx side: Private Sub Binddata(ByVal name As...
5
by: ric_deez | last post by:
Hi there, I would like to create a simple search form to allow users to search for a job number based on a number of parameters. I think I understand how to use parameteres associated with Stored...
9
by: fniles | last post by:
I am using VB.NET 2003 and SQL2000 database. I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1 parameter (varchar(10)) and returns the identity column value from that table....
2
by: suganya | last post by:
Hi I have to bind the DropDownList box with ID field hidden using SQLDataAdapter. For that I have given the coding as protected void Page_Load(object sender, EventArgs e) { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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 projectplanning, coding, testing,...

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.