Create Table Syntax Error In Field Definition
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss syntax error in field definition create table access the workings and policies of this site About Us Learn more about
Syntax Error In Field Definition Excel
Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions
Syntax Error In Field Definition Sql
Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Syntax Error In Create Table Statement
Join them; it only takes a minute: Sign up VB.Net OleDbException “Syntax error in field definition” up vote 1 down vote favorite I'm trying to create a table in an Access database through an OleDbCommand in VB.Net with the following SQL: CREATE TABLE InTemp (Month DATE, Description TEXT(255), Cost DOUBLE, Patron TEXT(255)); The code works fine in Access, syntax error in create table statement access 2013 but running it in VB.Net returns the OleDbException "Syntax error in field definition". Full VB code: Dim con As New OleDb.OleDbConnection con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = " + DatabaseLocale con.Open() Dim createInTemp As New OleDb.OleDbCommand("CREATE TABLE InTemp (Month DATE, Description TEXT(255), Cost DOUBLE, Patron TEXT(255));", con) createInTemp.ExecuteNonQuery() I know there's no problem with the connection as it works elsewhere in my program. Any help gladly appreciated! sql vb.net share|improve this question asked Jan 15 '14 at 11:33 rusty595 63 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote accepted I'd stab a guess at Month DATE being the problem here, Month is a function in MS Access so there's a good chance it's clashing. Try changing your query to CREATE TABLE InTemp ([Month] DATE, [Description] TEXT(255), [Cost] DOUBLE, [Patron] TEXT(255)) Also, as far as I am aware DATE is a type specific to the app, not necessarily the data store. I would use the actual underyling type which is DATETIME (same could be said for TEXT). See Microsoft Access
and get tips & solutions from a community of 418,471 IT Pros & Developers. It's quick & easy. CREATE TABLE syntax error in create table statement access 2010 P: n/a zufie I am learning SQL using MS Access until I get syntax error in create table statement access 2007 SQL Server. I am trying to create a table that includes time and date columns. I receive the logic error definition error: Syntax error in field definition. Here is my code: CREATE TABLE doughnut_ratings ( location VARCHAR(50), time DATETIME, date DATE, type CHAR(6), rating VARCHAR(50) comments VARCHAR(50) ); How can I fix http://stackoverflow.com/questions/21136321/vb-net-oledbexception-syntax-error-in-field-definition my code? Thanks, John Nov 19 '08 #1 Post Reply Share this Question 2 Replies P: n/a KC-Mass On Nov 19, 2:59 pm, zufie SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community https://social.msdn.microsoft.com/Forums/en-US/27d63ba1-33b6-4401-8103-3d02699aeb7b/oledb-create-table-field-definition-syntax-error?forum=adodotnetdataproviders Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: OleDB CREATE TABLE field syntax error definition syntax error Data Platform Development > ADO.NET Managed Providers Question 0 Sign in to vote I have some code that tries to create a sheet with in a workbook (.xlsx). The code is as follows: using (OleDbCommand cmd = new OleDbCommand("CREATE TABLE [MissingProducts](product CHAR(64),catalog CHAR(64))", candidateDebugConnection)) { cmd.ExecuteNonQuery(); } This code throws an syntax error in exception System.Data.OleDb.OleDbException: Syntax error in field definition. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() I can't see what is wrong with this code. Would someone in this group give me a second pair of eyes to see if you can see what is syntactically wrong with this code? Funny thing is, if I comment this code out and execute this code: using (OleDbCommand cmd = new OleDbCommand("CREATE TABLE [BCAmazon](product CHAR(64),variant CHAR(64),oid INT,category CHAR(255), categoryOid INT)", candidateDebugConnection)) { cmd.ExecuteNonQuery(); } It works just fine. No exceptions. I for the life of me cannot see the difference between these two statements. Ideas? Thank you. Kevin Burton Friday, February 04, 2011 1:39 AM Reply | Quote Answers 0 Sign in to vote Hi Kevin, It seems catalog is a keyword in the query, http://support.microsoft.com/kb/125948. Please try to use brackets on the keyword like "CREATE TABLE [MissingProducts](product CHAR(64)