EDN Admin
Well-known member
Hi All,
I had developed this code to insert data in to my sql server table using a webservice but I can see any paramters in the webservice can any one help me or edit my code please.
Here is my code
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
namespace Bremar2_Web
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
string customername1;
string customeremail1;
string shopname1;
string productcategory1;
string noofitems1;
string utilityname1;
string amountspent1;
[WebMethod]
private void BreamarRoad(string CusotmerName, string CusotmerEmail, string ShopName, string ProductCategory, string NoOfItems, string UtilityName, string AmountSpent)
{
SqlConnection Con = new SqlConnection
("conection string ");
Con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = Con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = string.Format("INSERT INTO [BremarRoad].[dbo].[TransactionTable] values(@CusotmerName,@CusotmerEmail,@ShopName,@ProductCategory,@NoOfItems,@UtilityName,@AmountSpent)");
SqlParameterCollection Sqlparams = cmd.Parameters;
Sqlparams.AddWithValue("@CusotmerName", customername1);
Sqlparams.AddWithValue("@CusotmerEmail", customeremail1);
Sqlparams.AddWithValue("@ShopName", shopname1);
Sqlparams.AddWithValue("@ProductCategory", productcategory1);
Sqlparams.AddWithValue("@NoOfItems", noofitems1);
Sqlparams.AddWithValue("@UtilityName",utilityname1);
Sqlparams.AddWithValue("@AmountSpent", amountspent1);
cmd.ExecuteNonQuery();
Con.Close();
}
}
}
[/code]
<br/>
I dont know what is wrong in my code I am unable to see parameters in the web service can any one help me.
I debug the solution I am getting a web service ,When I clicked on service description I am getting this
<pre class="prettyprint <?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tempuri.org/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/ <wsdl:types/> <wsdlortType name="Service1Soap"/> <wsdlortType name="Service1Soap12"/> -<wsdl:binding name="Service1Soap" type="tns:Service1Soap <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> </wsdl:binding> -<wsdl:binding name="Service1Soap12" type="tns:Service1Soap12 <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/> </wsdl:binding> -<wsdl:service name="Service1 -<wsdlort name="Service1Soap" binding="tns:Service1Soap <soap:address location="http://localhost:50409/Service1.asmx"/> </wsdlort> -<wsdlort name="Service1Soap12" binding="tns:Service1Soap12 <soap12:address location="http://localhost:50409/Service1.asmx"/> </wsdlort> </wsdl:service> </wsdl:definitions>[/code]
I want something with my parameters name so that I can test inserting data in to my table.<br/>
<hr class="sig Sri.Tummala
View the full article
I had developed this code to insert data in to my sql server table using a webservice but I can see any paramters in the webservice can any one help me or edit my code please.
Here is my code
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
namespace Bremar2_Web
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
string customername1;
string customeremail1;
string shopname1;
string productcategory1;
string noofitems1;
string utilityname1;
string amountspent1;
[WebMethod]
private void BreamarRoad(string CusotmerName, string CusotmerEmail, string ShopName, string ProductCategory, string NoOfItems, string UtilityName, string AmountSpent)
{
SqlConnection Con = new SqlConnection
("conection string ");
Con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = Con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = string.Format("INSERT INTO [BremarRoad].[dbo].[TransactionTable] values(@CusotmerName,@CusotmerEmail,@ShopName,@ProductCategory,@NoOfItems,@UtilityName,@AmountSpent)");
SqlParameterCollection Sqlparams = cmd.Parameters;
Sqlparams.AddWithValue("@CusotmerName", customername1);
Sqlparams.AddWithValue("@CusotmerEmail", customeremail1);
Sqlparams.AddWithValue("@ShopName", shopname1);
Sqlparams.AddWithValue("@ProductCategory", productcategory1);
Sqlparams.AddWithValue("@NoOfItems", noofitems1);
Sqlparams.AddWithValue("@UtilityName",utilityname1);
Sqlparams.AddWithValue("@AmountSpent", amountspent1);
cmd.ExecuteNonQuery();
Con.Close();
}
}
}
[/code]
<br/>
I dont know what is wrong in my code I am unable to see parameters in the web service can any one help me.
I debug the solution I am getting a web service ,When I clicked on service description I am getting this
<pre class="prettyprint <?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tempuri.org/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/ <wsdl:types/> <wsdlortType name="Service1Soap"/> <wsdlortType name="Service1Soap12"/> -<wsdl:binding name="Service1Soap" type="tns:Service1Soap <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> </wsdl:binding> -<wsdl:binding name="Service1Soap12" type="tns:Service1Soap12 <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/> </wsdl:binding> -<wsdl:service name="Service1 -<wsdlort name="Service1Soap" binding="tns:Service1Soap <soap:address location="http://localhost:50409/Service1.asmx"/> </wsdlort> -<wsdlort name="Service1Soap12" binding="tns:Service1Soap12 <soap12:address location="http://localhost:50409/Service1.asmx"/> </wsdlort> </wsdl:service> </wsdl:definitions>[/code]
I want something with my parameters name so that I can test inserting data in to my table.<br/>
<hr class="sig Sri.Tummala
View the full article