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

  • SEARCH
  • Home
  • 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 8190797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:45:28+00:00 2026-06-07T03:45:28+00:00

I am trying to use a web service to insert data to a table

  • 0

I am trying to use a web service to insert data to a table using visual studio. When I eun it, select the method and type in the parameters and then click on the Invoke button I get the following errors. I’ve checked the syntax of the insert statement and also tried using different syntax’s. But I’m getting the same errors. What am I doing wrong?

System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'User'.
  at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
  at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
  at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
  at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
  at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
  at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
  at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
  at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
  at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
  at Service.register(String fname, String lname, String email, String num, Int32 locID)

//Web Method to Insert values to table//

[WebMethod]
public void register(string fname, string lname, string email, string num, int locID)
{
    SqlConnection conn;
    conn = ConnectionManager.GetConnection();
    conn.Open();
    string cmdString = "INSERT into User values(@fname,@lname,@email,@num,@locID)";
    SqlCommand sqlCommand = new SqlCommand(cmdString, conn);
    sqlCommand.CommandType = CommandType.Text;

    sqlCommand.Parameters.Add("@fname", SqlDbType.Text).Value = fname;
    sqlCommand.Parameters.Add("@lname", SqlDbType.Text).Value = lname;
    sqlCommand.Parameters.Add("@email", SqlDbType.Text).Value = email;
    sqlCommand.Parameters.Add("@num", SqlDbType.Text).Value = num;
    sqlCommand.Parameters.Add("@locID", SqlDbType.Text).Value = locID;
    sqlCommand.ExecuteNonQuery();
    conn.Close();
}

///Connection Manager Class///

public class ConnectionManager
 {
    public static SqlConnection NewCon;
     public static string ConStr ="Data Source=ACER-PC\\SQLEXPRESS;Initial Catalog=DisasterAlert;Integrated Security=True";

    public static SqlConnection GetConnection()
   {
        NewCon = new SqlConnection(ConStr);
        return NewCon;
   }

 }
  • 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-06-07T03:45:29+00:00Added an answer on June 7, 2026 at 3:45 am

    “user” is a reserved word of SQL. try this

    "INSERT into [User] values(@fname,@lname,@email,@num,@locID)"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use a Web Service using PHP and SOAP. The Web Service
Im trying to use a Web Service to set an Airport code using Jquery
I am trying to use jax-ws to generate web service proxy classes, using the
I'm trying to use jQuery to get data from an ASP.NET web service (SharePoint
I'm trying to use the $.post method to call a web service, I've got
I'm trying to connect and use a web service method. I'm getting the following
I am trying to use third-party web service (php-based) in asp.net c# application, and
We're trying to use Axis2 to call a web service that cannot use HTTP/1.1
I am trying to use a web service built on asp.net wcf from iPhone
I'm trying to use Reducisaurus Web Service to minify CSS and Javascript but I've

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.