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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:04:06+00:00 2026-05-31T22:04:06+00:00

My issue is that I have created a table for a local db in

  • 0

My issue is that I have created a table for a local db in Visual Studio 10.0 using C# and I want to have an auto-incrementing field which I have setup. The table is created and the identity field seems to be setup correctly and everything seems fine, but I always get a syntax error on the insert when I use an identity field — so I imagine I have a stupid little typo, but perhaps this is just not supported using VS?

This is the create table string and execution:

-connection string omitted-
string createTableString = @"CREATE TABLE [Test](
[Test_ID] [int] IDENTITY (1,1) PRIMARY KEY NOT NULL,
[OtherField] [varchar] (50))";
SqlCommand command = new SqlCommand(createTableString, con); 
command.ExecuteNonQuery();

And this is what I’m using to insert into the table:

string insertString = @"INSERT INTO Test VALUES ('sometext')";
SqlCommand command1 = new SqlCommand(insertString, con);
command1.ExecuteNonQuery();

Note that I’ve tried this as well and get the same syntax error:

string insertString = @"INSERT INTO Test (OtherField) VALUES ('sometext')";
SqlCommand command1 = new SqlCommand(insertString, con);
command1.ExecuteNonQuery();

Also note that for this project I must do this via these scripting commands in Visual Studio. Is this possible? Thanks very much ahead of time.

  • 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-31T22:04:07+00:00Added an answer on May 31, 2026 at 10:04 pm

    The scripts look correct, I can only assume it has to do with the owner of the table. SQL makes the current user the owner of the table. Try [youruser].[Test] and see if that helps.

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

Sidebar

Related Questions

I have created a mac application using the WebView. But issue is that webView
Using the MySQL query below, I have created a pivot table which is pretty
I have a pretty common layout issue that I have traditionally used a table
I have an issue that is driving me a bit nuts: Using a UserProfileManager
I have created a table in APEX that has a PK that is incremented
I have created a TableRow layout model which I'm using as a template for
I have an issue. I have created 2 timestamp fields within a table 'created'
I have created one database and one table user in that while running my
I'm having an issue with backbone.js' models. I have a view that creates another
An odd issue that I have been trying to address in a project -

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.