PC Review


Reply
Thread Tools Rate Thread

asp.net 2 and stored procedures

 
 
=?Utf-8?B?VGRhclRkYXI=?=
Guest
Posts: n/a
 
      21st Nov 2005
Hello,
Not sure if there is a NEW way to do all this with asp.net 2,
here is an example of the way i used to do it and then I have questions to
follow:


store procedure example

CREATE PROCEDURE TEST_TEST
@TNUMBER NVARCHAR (10),
@ODRCOMMENT NVARCHAR(100) OUTPUT,
@RTASK NVARCHAR(1) OUTPUT

AS

SELECT @COMMENT = 'CANNOT COMPLETE ORDER'
SELECT @RTASK = 0

GO





default.asp page.....

SET Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = Application("Connection1_ConnectionString") ' pulls
from global.asa
Conn.Open
Set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = Conn
cm.CommandText = "TEST_TEST"
cm.CommandType = adCmdStoredProc
Set p = cm.Parameters
p.append cm.CreateParameter("@TNUMBER",adInteger,adParamInput,50)
p.append cm.CreateParameter("@COMMENT",adVarWChar,adParamOutput,100)
p.append cm.CreateParameter("@RTASK",adVarWChar,adParamOutput,1)

cm.Execute
If cm.Parameters("@RTASK").Value = 1 THEN
'DO SOMETHING ELSE
END IF

CM.CLOSE
CONN.CLOSE
SET CM = NOTHING
SET CONN = NOTHING





my question is:

1. How would this be done with Visual Studio 2005?
2. How would you connect to the web.config connectionStrings that has been
setup.

I seen this article of:
http://msdn.microsoft.com/data/dataa...vsgenerics.asp



but I don't think that relates as well as many other article that I have
looked at.



Struggling to get into the future or programming....

Tdar


 
Reply With Quote
 
 
 
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      22nd Nov 2005
Hi Tdar,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know how to execute a none
query command in ADO.NET. If there is any misunderstanding, please feel
free to let me know.

Executing a nonquery command and get output parameters in ADO.NET 2.0 is
just like what we did in ADO.NET 1.1. We needn't interop ADODB to do this.
But we use System.Data.SqlCommand object. It is similar to ADODB.Command
object. We use SqlCommand.ExecuteNonQuery to execute the command. You can
check the following link for more information on SqlCommand.

http://msdn.microsoft.com/library/de...us/dv_vbcode/h
tml/vbtskcodeexampleexecutestoredprocedure.asp

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdatasqlclientsqlcommandclasstopic.asp

To get data from web.config file, you can use
ConfigurationSettings.AppConfig property. Please see the following link:

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemconfigurationconfigurationsettingsclassappsettingstopic.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i convert stored procedures in sql to stored queries in ac =?Utf-8?B?YWRz?= Microsoft Access Queries 1 28th Aug 2006 01:49 PM
Map Stored Procedure dependencies from ASP pages through methods to stored procedures dwilliams@newportgroup.com Microsoft Dot NET 6 18th Mar 2005 03:02 AM
Map Stored Procedure dependencies from ASP pages through methods to stored procedures dwilliams@newportgroup.com Microsoft ADO .NET 2 17th Mar 2005 12:47 PM
Error: Executing Stored Procedures-- Cannot Pass TimeStamp Values From sqlCommand Object Parameter to A SQL Stored Procedure =?Utf-8?B?VGVjaE1E?= Microsoft ADO .NET 3 17th Mar 2004 04:03 AM
Stored Procedures Gary Nelson Microsoft Access Queries 1 19th Nov 2003 01:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:23 AM.