|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
asp.net 2 and stored proceduresNot 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/dataaccess/whidbey/default.aspx?pull=/library/en-us/dnvs05/html/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 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/default.asp?url=/library/en-us/dv_vbcode/h tml/vbtskcodeexampleexecutestoredprocedure.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-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/default.asp?url=/library/en-us/cpref/html/ frlrfsystemconfigurationconfigurationsettingsclassappsettingstopic.asp HTH. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." |
|||||||||||||||||||||||