Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7682483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:34:44+00:00 2026-05-31T18:34:44+00:00

Im trying to create an ASMX Web Service in Visual Web Developer.I have successfully

  • 0

Im trying to create an ASMX Web Service in Visual Web Developer.I have successfully Implemented the following

  • Created a Database with columns Email,Name
  • Created a Service

I have also specified connection string web.config like

<connectionStrings>
  <add name="mydb" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Database.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
    </connectionStrings>

But i get an SQL Exception “Incorrect Syntax Near @Name” after entering the data in the service form

[WebMethod]
public string insertuser(String UserName,String Email)
{

    string connectionString = ConfigurationManager.ConnectionStrings["mydb"].ConnectionString;

    SqlConnection sqlCon = new SqlConnection(connectionString);
    SqlCommand nonqueryCommand = sqlCon.CreateCommand();
    sqlCon.Open();
    nonqueryCommand.CommandText = "INSERT  INTO UID (Email, Name) VALUES (@Email, @Name";

    // Add Parameters to Command Parameters collection
    nonqueryCommand.Parameters.Add("@Email", SqlDbType.VarChar, 10);
    nonqueryCommand.Parameters.Add("@Name", SqlDbType.VarChar, 20);


    nonqueryCommand.Parameters["@Email"].Value = UserName;
    nonqueryCommand.Parameters["@Name"].Value = Email;


    nonqueryCommand.ExecuteNonQuery();
    return "done";

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:34:46+00:00Added an answer on May 31, 2026 at 6:34 pm

    as andomar has correctly pointed out you are missing closing bracket in your sql command

    just one thing you can generate insert command in you sql and just paste the generated sql into your code.

    IE your code should look like

    nonqueryCommand.CommandText = “INSERT INTO UID (Email, Name) VALUES
    (@Email, @Name)”;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a web service which returns some data and am trying to
I am working on an ASMX web service; trying to create a method that
I have a WSDL file and I am trying to create a web service
I have created a custom SharePoint web service that was deployed to, and successfully
I have created a new VS2008 ASP.Net Web service project, with the default name
I'm trying to do web service using android. I created the web service using
i'm trying to study about how to access external web services. I have created
I'm trying to create a http request to our web service, my test XML
I'm trying to create a simple AJAX & web service test (using C# .Net
I am trying to create a custom web service for Sharepoint 2010. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.