473,395 Members | 1,678 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,395 software developers and data experts.

Using MS Data Access application block to call stored procedure with parameters

JM
Hi,

I am using SQL Server 2000 and ASP.NET 2.0 and want to call a stored
procedure using Latest Enterprise Library 2.0. My stored procedure has
3 input parameters: CustId (int), RefId(int) and EmailId(varchar 200)
and it returns a dataset.

This is how I am trying to do:
-------------
int CustId = 1
int RefId = 1
string EmailId = "so******@email.com"

Database db = DatabaseFactory.CreateDatabase("ConnectionString") ;
//Need help in following line
DataSet ds = db.ExecuteDataSet("get_CustData", params object[]
parameterValues);
-------------------

Can anybody tell me how I can create this params object with the
values of all 3 parameters. And whats the best way to use enterprise
library for SQL Server database.

Thanks
JM

Feb 13 '07 #1
3 3284

You have to get hold of the instance of hte new 2.0 Abstract class
DbCommand
public DataSet GetOrdersByCustomerID(string customerID)
{
Database northwind = DatabaseFactory.CreateDatabase();

DbCommand command = northwind.GetSqlStringCommand ("SELECT
[OrderID],[OrderDate] FROM [Orders] WHERE [CustomerID] =
@CustomerID"); //OR DbCommand command =
northwind.GetStoredProcedure("dbo.uspGetAllOrders" )
northwind.AddInParameter(command, "@CustomerID",
DbType.String, customerID);
DataSet orders = new DataSet();

northwind.LoadDataSet(command, orders, "orders");

return orders;
}

I prefer the LoadDataSet over the ExecuteDataSet method.

You can find more examples by going here:

http://www.google.com/search?hl=en&q...InParameter%22

which is where I pulled the example from


"JM" <jm******@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Hi,

I am using SQL Server 2000 and ASP.NET 2.0 and want to call a stored
procedure using Latest Enterprise Library 2.0. My stored procedure has
3 input parameters: CustId (int), RefId(int) and EmailId(varchar 200)
and it returns a dataset.

This is how I am trying to do:
-------------
int CustId = 1
int RefId = 1
string EmailId = "so******@email.com"

Database db = DatabaseFactory.CreateDatabase("ConnectionString") ;
//Need help in following line
DataSet ds = db.ExecuteDataSet("get_CustData", params object[]
parameterValues);
-------------------

Can anybody tell me how I can create this params object with the
values of all 3 parameters. And whats the best way to use enterprise
library for SQL Server database.

Thanks
JM

Feb 13 '07 #2
JM
Hi,

Thanks for the prompt reply. I am able to use sp using DBCommand
object.

Thanks
JM

On Feb 13, 11:23 am, "sloan" <s...@ipass.netwrote:
You have to get hold of the instance of hte new 2.0 Abstract class
DbCommand

public DataSet GetOrdersByCustomerID(string customerID)
{
Database northwind = DatabaseFactory.CreateDatabase();

DbCommand command = northwind.GetSqlStringCommand ("SELECT
[OrderID],[OrderDate] FROM [Orders] WHERE [CustomerID] =
@CustomerID"); //OR DbCommand command =
northwind.GetStoredProcedure("dbo.uspGetAllOrders" )
northwind.AddInParameter(command, "@CustomerID",
DbType.String, customerID);
DataSet orders = new DataSet();

northwind.LoadDataSet(command, orders, "orders");

return orders;

}

I prefer the LoadDataSet over the ExecuteDataSet method.

You can find more examples by going here:

http://www.google.com/search?hl=en&q...ommand+%22AddI...

which is where I pulled the example from

"JM" <jmcha...@gmail.comwrote in message

news:11**********************@v33g2000cwv.googlegr oups.com...
Hi,
I am using SQL Server 2000 and ASP.NET 2.0 and want to call a stored
procedure using Latest Enterprise Library 2.0. My stored procedure has
3 input parameters: CustId (int), RefId(int) and EmailId(varchar 200)
and it returns a dataset.
This is how I am trying to do:
-------------
int CustId = 1
int RefId = 1
string EmailId = "someb...@email.com"
Database db = DatabaseFactory.CreateDatabase("ConnectionString") ;
//Need help in following line
DataSet ds = db.ExecuteDataSet("get_CustData", params object[]
parameterValues);
-------------------
Can anybody tell me how I can create this params object with the
values of all 3 parameters. And whats the best way to use enterprise
library for SQL Server database.
Thanks
JM- Hide quoted text -

- Show quoted text -

Feb 13 '07 #3
For informational purposes, the params object[] array of parameter values can
be constructed like this:

object[] myParams = { "Abc", 23, DateTime.Now, "etc."};

Pass "myParams" in the last position of the method signature.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"JM" wrote:
Hi,

I am using SQL Server 2000 and ASP.NET 2.0 and want to call a stored
procedure using Latest Enterprise Library 2.0. My stored procedure has
3 input parameters: CustId (int), RefId(int) and EmailId(varchar 200)
and it returns a dataset.

This is how I am trying to do:
-------------
int CustId = 1
int RefId = 1
string EmailId = "so******@email.com"

Database db = DatabaseFactory.CreateDatabase("ConnectionString") ;
//Need help in following line
DataSet ds = db.ExecuteDataSet("get_CustData", params object[]
parameterValues);
-------------------

Can anybody tell me how I can create this params object with the
values of all 3 parameters. And whats the best way to use enterprise
library for SQL Server database.

Thanks
JM

Feb 13 '07 #4

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

Similar topics

2
by: Yves Touze | last post by:
Hi All, I'm trying to migrate from SQL Server 7.0 to SQL Server 2000. I've got some ASP page which call VB components that retrieve shaped recordsets from SQL Server using the MSDATASHAPE...
0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
9
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...
1
by: bjs | last post by:
I am using MS SQL Server 2000 and 2005, IIS 5,0 and ASP. I am able to display data that has been selected from a Unicode column in the database in all languages except Japanese (I get question...
9
by: weirdwoolly | last post by:
Hopefully someone will be able to help. I have written a stored procedure in C++ called from a Java test harness to validate the graphic data types in C++ and their use. I have declared the...
2
by: acw | last post by:
On a SQL Server 2000 db I would like to setup a stored procedure that accesses couple tables and runs the extended stored procedure xp..cmdshell. The goal is to grant users with limited privileges...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
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,...
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
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...

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.