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

c# call stored procedure webservice

1 Bit
good day everyone,

I currently have this project where I call the parameter in this method with an XSD and it should save the data in a Stored Procedure. I have made several attempts. When entering the XSD, it only returns the XSD but does not return the output parameter.

Here is the code:

Expand|Select|Wrap|Line Numbers
  1.   internal static string ValidateCreateRequestDeductibleXml(string data)
  2.         {
  3.  
  4.  
  5.  
  6.             DsCreateRequestDeductible dsCreateRequestDeductible = new DsCreateRequestDeductible();
  7.  
  8.             try
  9.             {
  10.                 if (!data.Equals(String.Empty))
  11.                 {
  12.                     System.IO.StringReader xml = new System.IO.StringReader(data);
  13.                     dsCreateRequestDeductible.ReadXml(xml);
  14.                     Console.WriteLine("El código es: ");
  15.                 }
  16.                 else
  17.                 {
  18.                     SqlParameter myOutputParameter = new SqlParameter("@sp_mjsError", SqlDbType.Int);
  19.                     myOutputParameter.Direction = ParameterDirection.Output;
  20.                 }
  21.             }
  22.             catch (XmlException e)
  23.             {
  24.                 Console.WriteLine("Error");
  25.             }
  26.  
  27.             foreach (DataRow row in dsCreateRequestDeductible.Tables[0].Rows)
  28.             {
  29.                 CreateRequest createRequestdeductible = new CreateRequest();
  30.                 createRequestdeductible.ProcessId = Convert.ToInt32(row["id_proceso"]);
  31.                 createRequestdeductible.CompanyCode = Convert.ToDecimal(row["cod_cia"]);
  32.                 createRequestdeductible.ClaimNumber = Convert.ToDecimal(row["nro_stro"]);
  33.                 createRequestdeductible.ExcerciseYear = Convert.ToDecimal(row["aaaa_ejercicio"]);
  34.                 createRequestdeductible.SubClaimNumber = Convert.ToDecimal(row["nro_subsiniestro"]);
  35.                 createRequestdeductible.BranchExpCode = Convert.ToDecimal(row["cod_suc_exp"]);
  36.                 createRequestdeductible.PrefixCode = Convert.ToDecimal(row["cod_ramo"]);
  37.                 createRequestdeductible.RegistryDate = Convert.ToDateTime(row["fec_registro"]);
  38.                 createRequestdeductible.RiskDescription = Convert.ToString(row["desc_riesgo"]);
  39.                 createRequestdeductible.ItemCoverageCode = Convert.ToDecimal(row["cod_con_cob"]);
  40.                 createRequestdeductible.ProtectionCode = Convert.ToDecimal(row["cod_amparo"]);
  41.                 createRequestdeductible.PolicyNumber = Convert.ToDecimal(row["nro_poliza"]);
  42.                 createRequestdeductible.AttachNumber = Convert.ToDecimal(row["nro_anexo"]);
  43.                 createRequestdeductible.ItemNumber = Convert.ToDecimal(row["nro_item"]);
  44.                 createRequestdeductible.DepositCode = Convert.ToDecimal(row["cod_abona"]);
  45.                 createRequestdeductible.DocumentTypeCode = Convert.ToDecimal(row["cod_tipo_doc"]);
  46.                 createRequestdeductible.DocumentNumber = Convert.ToString(row["nro_doc"]);
  47.                 createRequestdeductible.SubConceptAmount = Convert.ToDecimal(row["imp_subconcepto"]);
  48.                 createRequestdeductible.PaymentCode = Convert.ToDecimal(row["cod_con_pago"]);
  49.                 createRequestdeductible.BillDate = Convert.ToDateTime(row["fec_factura"]);
  50.                 createRequestdeductible.PayBranchCode = Convert.ToDecimal(row["cod_suc_gira"]);
  51.                 createRequestdeductible.TotalPartialPayment = Convert.ToDecimal(row["pgo_total_parcial"]);
  52.                 createRequestdeductible.StatusOperationCode = Convert.ToDecimal(row["cod_estado_op"]);
  53.                 createRequestdeductible.EstimatedPaymentDate = Convert.ToDateTime(row["fec_estimada_pago"]);
  54.                 createRequestdeductible.PaymentTypeCode = Convert.ToDecimal(row["cod_tipo_pago"]);
  55.                 createRequestdeductible.PaymentNumber = Convert.ToDecimal(row["nro_pago"]);
  56.                 createRequestdeductible.StatusCode = Convert.ToDecimal(row["cod_estado"]);
  57.                 createRequestdeductible.UserCode = Convert.ToString(row["cod_usuario"]);
  58.                 createRequestdeductible.ConceptCode = Convert.ToInt32(row["cod_concepto"]);
  59.                 createRequestdeductible.FormalizedDate = Convert.ToDateTime(row["fec_formalizado"]);
  60.                 createRequestdeductible.EstimatedCode = Convert.ToDecimal(row["cod_estim"]);
  61.                 createRequestdeductible.ThridCode = Convert.ToDecimal(row["cod_tercero"]);
  62.                 createRequestdeductible.CurrencyCode = Convert.ToInt16(row["cod_moneda"]);
  63.                 createRequestdeductible.ExchangeAmount = Convert.ToDecimal(row["imp_cambio"]);
  64.  
  65.                 if (!(row["cod_conducto"] is DBNull))
  66.                 {
  67.                     createRequestdeductible.ConduitCode = Convert.ToInt16(row["cod_conducto"]);
  68.                 }
  69.  
  70.  
  71.                 if (!(row["cod_banco"] is DBNull))
  72.                 {
  73.                     createRequestdeductible.BankCode = Convert.ToInt16(row["cod_banco"]);
  74.                 }
  75.  
  76.  
  77.                 if (!(row["cod_moneda"] is DBNull))
  78.                 {
  79.                     createRequestdeductible.CurrencyCode = Convert.ToInt16(row["cod_moneda"]);
  80.                 }
  81.  
  82.                 UnderWritingService2GDelegate delegateValidatePolicy = new UnderWritingService2GDelegate();
  83.                 data = delegateValidatePolicy.ProcessCreateRequestDeductible(createRequestdeductible);
  84.             }
  85.             return data;
  86.         }
  87.  
  88.  
Could you help me how do I call the output parameter please? so that I read the XSD and save it in the SQL database
Dec 12 '22 #1
1 9890
Arushi
7 Nibble
You will need to use a SqlCommand object to call the stored procedure, and pass the output parameter as a parameter to the command. You will also need to set the SqlCommand object's CommandType property to CommandType.StoredProcedure, and set the SqlCommand object's Parameters property to a SqlParameterCollection object, where you can add the output parameter.

Expand|Select|Wrap|Line Numbers
  1. For example:
  2.  
  3. using (SqlCommand cmd = new SqlCommand("spCreateRequestDeductible", Connection))
  4. {
  5.     cmd.CommandType = CommandType.StoredProcedure;
  6.  
  7.     SqlParameterCollection parameters = cmd.Parameters;
  8.     SqlParameter outputParameter = new SqlParameter("@sp_mjsError", SqlDbType.Int);
  9.     outputParameter.Direction = ParameterDirection.Output;
  10.     parameters.Add(outputParameter);
  11.  
  12.     // Add other parameters here
  13.  
  14.     cmd.ExecuteNonQuery();
  15.  
  16.     int outputValue = (int)outputParameter.Value;
  17.     // Do something with outputValue
  18. }
Dec 12 '22 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Luis | last post by:
I'm using code similar to the following in an asp page to call a stored procedure that does a select on a SQLServer 2000 table: dim rs, SelectSql SelectSql = "EXEC spSelectStuff @param = '" &...
2
by: syoung | last post by:
I would like to know if anyone knows how to execute a stored procedure from ASP.NET 2.0. I'm using the NorthWind database and I'm trying to execute the "CustOrderHist" stored procedure. The...
1
by: Jenny C. | last post by:
Hi I am fairly new to .NET, and I am having a hard time to call a stored procedure from C# code in a windows application I have tested my connection (and login) several time and it is OK. If I...
6
by: Sam | last post by:
I had created stored procedure at SQL Server 2000 and how do I call it via ASP.Net using VB Language? CREATE PROCEDURE STK As if exists (select * from dbo.sysobjects where id =...
3
by: sarma | last post by:
Hi friends, I created a stored procedure in MySQL like create procedure p() select NOW(); I write a C program, from which i wish to call this stored procedure, i used both...
3
by: JM | last post by:
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...
1
by: eholz1 | last post by:
Hello PHP Group, Is there any advantages (or disadvantages) in using mysqli instead of mysql (querys, connections to database, etc). I am currently using mysql_connect, and things like this:...
2
by: E11esar | last post by:
Hello there. I am going in bit of a circle with this matter; First some background: I am trying to upload the details of a CSV file into an Oracle table. I am using a StreamReader to copy a line...
3
akashazad
by: akashazad | last post by:
Hi Friends My question is "can we call Stored Procedure from a User Defined Function in SQL" If yes then pl tell me how? If No then pl tell me why not ? While I was trying finding...
1
by: shubhageetha | last post by:
I have stored procedure in sql server as follows USE GO /****** Object: StoredProcedure . Script Date: 09/30/2014 16:22:48 ******/ SET ANSI_NULLS OFF GO SET QUOTED_IDENTIFIER OFF GO --...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
isladogs
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...
0
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...

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.