Web service at asp.net

I want to create a web service to access a page or connect to a database.

I have finished connecting to the database

but I can’t understand how I can create a registration page in a web service .. since there is no interface in the web service.

Tell me please,

my web service code:

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Data; using System.Data.SqlClient; namespace WcfService1 { /// <summary> /// Summary description for WebService1 /// </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 WebService1 : System.Web.Services.WebService { string Connection = "Data Source=SHUMAILA-PC;Initial Catalog=kse;User ID=sa;Password=sa"; [WebMethod] public void SQLconn() { SqlConnection DataConnection = new SqlConnection(Connection); // the string with T-SQL statement, pay attention: no semicolon at the end of //the statement string Command = "INSERT INTO login VALUES ('hina','me12')"; // create the SQLCommand instance SqlCommand DataCommand = new SqlCommand(Command, DataConnection); // open the connection with our database DataCommand.Connection.Open(); // execute the statement and return the number of affected rows int i = DataCommand.ExecuteNonQuery(); //close the connection DataCommand.Connection.Close(); } } } 
0
source share
2 answers

but I can’t understand how I can create a web service registration page .. since there is no interface in the web service.

In fact, your reasoning is correct. The ASMX web service implements the SOAP protocol and cannot have any GUI. The best development of the web application interface in .NET you can use, for example, ASP.NET. This way you can create an ASP.NET application that will use this web service. By the way, ASX web services are considered obsolete technology, and you should use WCF instead.

0
source

There are different methods. However, its a common way to use Ajax requests to your web method through AJAX.

Here's an older walk, but its still relevant - http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx

It demonstrates two approaches using jQuery (which I recommend) and Microsoft Ajax.

Here are some more worthy links -

http://www.asp.net/ajaxlibrary/jquery_dibs.ashx

0
source

All Articles