Syntax Error - C# Access data insert
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=14782
Printed Date: 29 March 2026 at 4:18pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Syntax Error - C# Access data insert
Posted By: chuksted
Subject: Syntax Error - C# Access data insert
Date Posted: 21 April 2005 at 11:57am
Syntax error (missing operator) in query expression 'Test mailto:Company%27,%27Address%27,%27Shipping%27,%27Houston%27,%27000-000-0000%27,%27sales@testcoy.com - 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(); } } }
------------- Chuksted2003
|
Replies:
Posted By: Lofty
Date 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+"')";
|
Posted By: chuksted
Date Posted: 22 April 2005 at 7:44am
Thank you so much Lofty; that worked like magic .
- Ted
------------- Chuksted2003
|
|