0

I want to create an web service for 'sign up' page or database connectivity..

I am done with database connectivity

but i am unable to get how ca i design an sign up page in web service.. as there is no interface in web service.

Please tell me

my web service code is :

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();

        }

    }
}
Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • Can I suggest to NOT do your db call like that. At very least do some validation as well as separate it out into a Service Layer. As for submitting the data, you just have to "POST" it like you do a form. – Chase Florell Sep 19 '11 at 21:25
  • Sounds Good. ! but I am new to asp.net. – Shumaila Hameed Khan Sep 19 '11 at 21:32
  • You don't want to risk SQL Injection or other attacks on your system. Look into LINQ to SQL or another ORM and separate all your database logic into a separate Service Class. Then call that service class from your WebService method. Ensure you're cleaning your data before inserting it as to keep the nasties away. – Chase Florell Sep 19 '11 at 21:53

2 Answers2

0

but i am unable to get how ca i design an sign up page in web service.. as there is no interface in web service.

In fact your reasoning is correct. An ASMX web service implements the SOAP protocol and cannot have any GUI interface whatsoever. Top design an interface of a web application in .NET you could use ASP.NET for example. So you could create an ASP.NET application which will consume this web service. By the way ASX web services are considered as deprecated technology and you should use WCF instead.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
0

There are different techniques. However, its common to utilize Ajax requests to your webmethod via AJAX.

Here is an older walk-through but its still valid - 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 decent links -

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

Kris Krause
  • 7,304
  • 2
  • 23
  • 26