Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Syntax Error - C# Access data insert
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Syntax Error - C# Access data insert

 Post Reply Post Reply
Author
chuksted View Drop Down
Newbie
Newbie


Joined: 20 January 2005
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote chuksted Quote  Post ReplyReply Direct Link To This Post Topic: Syntax Error - C# Access data insert
    Posted: 21 April 2005 at 11:57am
Syntax error (missing operator) in query expression 'Test Company','Address','Shipping','Houston','000-000-0000','sales@testcoy.com)'.

Here is the code:

        //[STAThread]
        static void Main()
        {
        Application.Run(new StockPile());
        }

        private void StockPile_Load(object sender, System.EventArgs e)
        {
            myOleDbConn = new OleDbConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectionString")) ;
        }

        private void tabCoyInfo_Click(object sender, System.EventArgs e)
        {

        }

        private void btnSave_Click(object sender, System.EventArgs e)
        {
            OleDbCommand myOleDbCommand = new OleDbCommand();
            // Open the connection
            myOleDbConn.Open();
            //Assign the connection property.
            myOleDbCommand.Connection=my OleDbConn;
            try
            {
                // Insert new company
                myOl eDbCommand.CommandText = "INSERT INTO CompanyInfo (coyName, coySymbol, coyBusType, coyLocation, coyPhone, coyEMail) VALUES ("+txtCoyName.Text+"','"+txtSymbol.Text+"','"+txtBusType.Text+"','"+txtLocation.Text+"','"+t xtPhone.Text+"','"+txtEmail.Text+")";
                myOl eDbCommand.ExecuteNonQuery();
                Mess ageBox.Show("New Customer data recorded!");
            }
            catch(Exception ex)
            {
                Mess ageBox.Show("Error occurred, customer data could not be recorded: " + ex.Message);
            }
            finally
            {
                // Close the connection if it is open
                if (myOleDbConn.State==ConnectionState.Open)
                {
                &nbs p;   myOleDbConn.Close();
                }
            }
        }
Back to Top
Lofty View Drop Down
Newbie
Newbie
Avatar

Joined: 03 April 2005
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lofty Quote  Post ReplyReply Direct Link To This Post Posted: 22 April 2005 at 4:03am
you are missing the final ' mark from the end of the email

,'"+txtEmail.Text+")";

that should be

,'"+txtEmail.Text+"')";


Back to Top
chuksted View Drop Down
Newbie
Newbie


Joined: 20 January 2005
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote chuksted Quote  Post ReplyReply Direct Link To This Post Posted: 22 April 2005 at 7:44am
Thank you so much Lofty; that worked like magic .

- Ted  
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.