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

        }

    }
}
3
  • 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. Commented Sep 19, 2011 at 21:25
  • Sounds Good. ! but I am new to asp.net. Commented Sep 19, 2011 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. Commented Sep 19, 2011 at 21:53

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

9 Comments

but how can I link my web service with my GUI. I am totally new to asp.net.Please help me
Can i Do it by adding a new item "Web form" ?
@Shumaila Hameed Khan, in your ASP.NET application you could add a Web Service Reference which will create a strongly typed proxy allowing you to invoke this service. Also if you are new to this you should first read some tutorials and come back with specific questions here.
WCF is great, but "can" be overkill depending on the situation. I've been building web services using RESTful URL's and ASP.NET MVC and it works very well.
why ASX services are considered as depreciated ?
|
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.