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 6847741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:46:56+00:00 2026-05-27T00:46:56+00:00

SqlConnection sqlConnection = new SqlConnection(sqlConnectionString); SqlCommand command = new SqlCommand(); command.CommandText = INSERT INTO

  • 0
SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
SqlCommand command = new SqlCommand();

command.CommandText = 
   "INSERT INTO [Users] 
    VALUES (Username=@username, Firstname=@firstname
          , Lastname=@lastname, ProfilePic=NULL, Bio=@bio, Email=@email
          , EmailIsVerified=@emailverified, Hash=@hash, CompanyID=@companyid)";
command.Parameters.AddWithValue("@username", m_username);
command.Parameters.AddWithValue("@firstname", m_firstname);
command.Parameters.AddWithValue("@lastname", m_lastname);
command.Parameters.AddWithValue("@bio", m_bio);
command.Parameters.AddWithValue("@email", m_email);
command.Parameters.AddWithValue("@emailverified", (m_emailIsVerified ? "yes" : "no"));
command.Parameters.AddWithValue("@hash", m_hash);
command.Parameters.AddWithValue("@companyid", m_companyID);
command.CommandType = CommandType.Text;
command.Connection = sqlConnection;

sqlConnection.Open();

command.ExecuteNonQuery();

sqlConnection.Close();

With the above code I get the “Syntax error near =” error. What have I done wrong?

  • 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-27T00:46:57+00:00Added an answer on May 27, 2026 at 12:46 am

    In your INSERT statement do not use Username=@username etc, because that is not valid SQL. It should look like this instead:

    command.CommandText = "INSERT INTO [Users] VALUES (@username, @firstname, @lastname, NULL, @bio, @email, @emailverified, @hash, @companyid)"; 
    

    This assumes the values are in the same order as the columns in the database, otherwise you will need to specify the columns too.

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

Sidebar

Related Questions

SqlConnection connection = new SqlConnection(cnnString); try { connection.Open(); SqlCommand command = new SqlCommand([dbo].[tblMessages_Insert], connection);
My code: SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings[myConnectionString].ConnectionString); SqlCommand cmd = new SqlCommand(); //.......... cmd.CommandText
Assume the following code: using (SqlConnection conn = new SqlConnection(connectionString)) { ... using (SqlCommand
if (validateEmailId(email)) { pictureBox5.Visible = true; SqlConnection con = new SqlConnection(conection string); SqlCommand cmd2
Can I use this approach efficiently? using(SqlCommand cmd = new SqlCommand(GetSomething, new SqlConnection(Config.ConnectionString)) {
SqlConnection con = new SqlConnection(Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Db.mdf;Integrated Security=True;User Instance=True); SqlCommand com2 = new SqlCommand(); com2.Connection
SqlConnection conn1 = new SqlConnection(Server=ILLUMINATI; + Database=DB;Integrated Security= true); SqlCommand COMM = new SqlCommand(select
SqlConnection conn = new SqlConnection(AllQuestionsPresented.connectionString); SqlCommand cmd = new SqlCommand(sb.ToString(), conn); cmd.Parameters.Add(@ThreadsID, SqlDbType.Int).Value =
I have the following query: SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[chestionar].ConnectionString); SqlCommand cmd = new
I have the following situation: using (SqlConnection conexao = new SqlConnection(ConnectionString)) { SqlCommand comando

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.