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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:36:18+00:00 2026-05-26T11:36:18+00:00

I wrote a code to add row that getting the values from textboxes i

  • 0

I wrote a code to add row that getting the values from textboxes

i wrote a code but it doesn’t work propatly.
when Idebugg it i get this error:”Syntax error in the INSERT INTO command”
i don’t know how to make it works.
Heres the code:

        private void addRow_Click(object sender, EventArgs e)
    {
        string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Projects_2012\\Project_Noam\\Access\\myProject.accdb";
        OleDbConnection myConnection = new OleDbConnection(connectionString);
        string myAddingQuery = string.Format("insert into tblCodons(codonsCodon1, codonsCodon3, " +
        "codonsTriplet1, codonsTriplet2, codonsTriplet3, codonsTriplet4, " +
        "codonsTriplet5, codonsTriplet6, codonsFullName" +
        ") values ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8})", 
        codon1.Text, codon3.Text, triplet1.Text, triplet2.Text,
         triplet3.Text, triplet4.Text, triplet5.Text, triplet6.Text,
        fullName.Text);
        OleDbCommand myCommand = new OleDbCommand(myAddingQuery);
        myCommand.Connection = myConnection;
        myConnection.Open();
        myCommand.ExecuteNonQuery();
        myCommand.Connection.Close();

    }

TNX to the helpers!

  • 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-26T11:36:19+00:00Added an answer on May 26, 2026 at 11:36 am

    It’s probably complaining because you’re not quoting any of the values. However, you shouldn’t be including the values directly in the SQL anyway – you should use a parameterized statement. That way:

    • You separate code from data, which is always a good thing.
    • You avoid SQL injection attacks.
    • You don’t need to worry about conversion formats for things like dates and numbers.

    See the docs for OleDbCommand.Parameters for a full example. Your code would probably become something like:

    private void addRow_Click(object sender, EventArgs e)
    {
        string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + 
            "Data Source=C:\\Projects_2012\\Project_Noam\\Access\\myProject.accdb";
        using (OleDbConnection connection = new OleDbConnection(connectionString))
        {
            string sql = "insert into tblCodons(codonsCodon1, codonsCodon3, " +
                "codonsTriplet1, codonsTriplet2, codonsTriplet3, codonsTriplet4, " +
                "codonsTriplet5, codonsTriplet6, codonsFullName" +
                ") values (?, ?, ?, ?, ?, ?, ?, ?, ?)";
            using (OleDbCommand command = new OleDbCommand(sql, connection))
            {
                connection.Open();
                command.Parameters.AddWithValue("codon1", codon1.Text);
                command.Parameters.AddWithValue("codon3", codon3.Text);
                command.Parameters.AddWithValue("triplet1", triplet1.Text);
                command.Parameters.AddWithValue("triplet2", triplet2.Text);
                command.Parameters.AddWithValue("triplet3", triplet3.Text);
                command.Parameters.AddWithValue("triplet4", triplet4.Text);
                command.Parameters.AddWithValue("triplet5", triplet5.Text);
                command.Parameters.AddWithValue("triplet6", triplet6.Text);
                command.Parameters.AddWithValue("fullName", fullName.Text);
                command.ExecuteNonQuery();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a code in ASP.NET that read data from SQL Table and show
I want to reuse some code I wrote to add some functionality to a
I wrote some code with a lot of recursion, that takes quite a bit
Background I've picked up some incomplete work from another developer that involves displaying the
i am adding some data from my jsp page( Add.jsp ). after adding that
I just wrote some code, looked it over, and wanted to cry. Lines that
I am exporting gridview data to excel but that excel file add the some
I am trying to write simple Visual Studio Add-In for code generation. In my
I wrote code to set permission of the folder. Function I developed was public
I wrote this code I have these errors Cannot implicitly convert type x.Program.TreeNode' to

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.