Oledb Syntax Error In From Clause
Contents |
here for a quick overview of the site Help Center Detailed answers to syntax error in from clause c# access any questions you might have Meta Discuss the workings and
Syntax Error In From Clause Oledbdataadapter
policies of this site About Us Learn more about Stack Overflow the company Business Learn
Syntax Error (missing Operator) In Query Expression
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How do I resolve the OleDb error “Syntax error in FROM clause”? up vote 0 down vote favorite Presently I am attempting to import a CSV file using this function: public DataSet ImportCommaSeparatedValueFileToDataSet(string SourceFile) { var dsImportCSVtoDataSetReturn = new DataSet(); using (var objAdapter1 = new OleDbDataAdapter()) { String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + SourceFile.Substring(0, SourceFile.LastIndexOf(@"\")) + ";Extended Properties='text;HDR=Yes;FMT=Delimited'"; var objConnection = new OleDbConnection(sConnectionString); objConnection.Open(); var objCmdSelect = new OleDbCommand("SELECT * FROM " + SourceFile, objConnection); objAdapter1.SelectCommand = objCmdSelect; objAdapter1.Fill(dsImportCSVtoDataSetReturn); objConnection.Close(); } return dsImportCSVtoDataSetReturn; } When I attempt to import a file that has no space in the filename, it works fine. When I attempt to import the following file: D:\Workspace\WoldCard export.csv Then I receive the following exception: excException = {"Syntax error in FROM clause."} Source = "Microsoft JET Database Engine" StackTrace " at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)\r\n at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)\r\n at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)\r\n at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)\r\n at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)\r\n at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)\r\n at System.Data.C
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask http://stackoverflow.com/questions/14445561/how-do-i-resolve-the-oledb-error-syntax-error-in-from-clause Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Syntax Error in From clause Excel up vote 1 down vote favorite public void SetConnection(string text1, http://stackoverflow.com/questions/16646926/syntax-error-in-from-clause-excel string text2, string text3, string text4, string text5, string text6, string text7) { connectionString1 = "Initial Catalog=testdb; Data Source=work\\sqlexpress"; database = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\\Users\\test.xls';Extended Properties= \"Excel 8.0;HDR=Yes;IMEX=1\";"); database.Open(); database1 = new OleDbConnection("Provider=SQLOLEDB.1;" + connectionString1); database1.Open(); } data1 = DataAccess.DatabaseTables("SELECT * from [Sheet1$])", DataAccess.database); public DataTable DatabaseTables(string QueryString, OleDbConnection DataConnection) { OleDbCommand SQLQuery = new OleDbCommand(); DataTable data = null; SQLQuery.Connection = null; OleDbDataAdapter dataAdapter = null; SQLQuery.CommandText = QueryString; SQLQuery.Connection = DataConnection; data = new DataTable(); dataAdapter = new OleDbDataAdapter(SQLQuery); dataAdapter.Fill(data); return data; } I am getting exception "Syntax error in from clause" for the line of code starting at data1. This line calls the function below it DatabaseTables which generates this exception. I have also included the connection string which uses jet etc in the fn SetConnection. I think the problem could be the connection string itself. Currently
in FROM clause The SitePoint Forums have moved. You can now find them here. This forum is now closed to new posts, but you can http://www.sitepoint.com/forums/showthread.php?242119-Syntax-error-in-FROM-clause browse existing content. You can find out more information about the move http://dailydoseofexcel.com/archives/2006/01/06/syntax-error-in-from-clause/ and how to open a new account (if necessary) here. If you get stuck you can get support by emailing forums@sitepoint.com If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register syntax error link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. SitePoint Sponsor User Tag List Results 1 to 7 of 7 Thread: Syntax error in FROM clause Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Mar 10, 2005,22:16 #1 russdawg View syntax error in Profile View Forum Posts SitePoint Enthusiast Join Date Mar 2005 Posts 56 Mentioned 0 Post(s) Tagged 0 Thread(s) Syntax error in FROM clause Hey guys. I want to say this is a great book and it is teaching me much. I have a small problem when going through chapter 14: User Authentication. I am getting this error which I am sure is an easy fix. System.Data.OleDb.OleDbException: Syntax error in FROM clause. First: USER is the name of my table that stores the Username and Password Second: USER_LOGIN & USER_PASS are what I have named my fields. Here is the code: Sub LoginUser(s As Object, e As EventArgs) Dim blnAuthenticate As Boolean = Authenticate(username.Text, password.Text) If blnAuthenticate Then FormsAuthentication.RedirectFromLoginPage(username.Text, False) Else lblError.Text = "Your login was invalid. Please try again." End If End Sub Function Authenticate(strUsername As String, strPassword As String) As Boolean Dim objConn As New OleDbConnection(ConfigurationSettings.AppSettings("DSN")) Dim objCmd As OleDbCommand Dim objDR As OleDbDataReader Dim userFound As Boolean objCmd = New OleDbCommand("SELECT * FROM USER WHERE USER_LOGIN='" & strUsername & "' AND USER_PASS='" & strPassword & "'", objConn) objConn.Open() objDR = objCmd.ExecuteReader() userFound = objDR.Read() objDR.C
Uncategorized on January 6, 2006. The company for whom I now work buys some version of Microsoft Office that includes Powerpoint and Publisher, but not Access. I'd be more specific, but I don't really know what the versions of Office are. But no Access? I need to figure out a way to fix that! In the mean time, I've downloaded Nwind.mdb from Office Online, which I assume is the same as the Northwind.mdb sample database that ships with Access. When I attempt to create an external data query in Excel 2003, I get this message at the end of the query wizard: I don't typically use the query wizard, but I got the same error message in the MS Query interface when I tried to add a field by dragging it from the tables area to the query area. Furthermore, I got the same error when I tried to manually enter this SQL statement: SELECT * FROM Categories I'm not quite sure how I figured this next one out, but the problem was fixed by manually entering (manually means in the SQL dialog box from within MS Query): SELECT * FROM [Categories] I wasn't able to avoid the error using any kind GUI - it had to be manually typed. When I use ADO via VBA, I'm not required to enclose the table name in brackets in any SQL statements I write. The connection statement I use to connect via ADO is exactly the same as the Connection property of the QueryTable object except that the ODBC is removed from the front of it. Does that mean the ODBC driver is the problem? Why do I have an ODBC driver for Access if I don't have Access installed? Is it time to learn MySQL so I don't have to pay for Access? By Dick Kusleika in Uncategorized on January 6, 2006. 18 Replies Post navigation ← Conditional Formatting and Noncontiguous Ranges ExcelKBs Forum → 18 thoughts on “Syntax Error in FROM Clause” doco January 6, 2006 at 7:48 pm MySQL would be an interesting touch to DDE… :) doco January 6, 2006 at 7:57 pm Seriously, I have had other problems with MSQ. I just finished a project which had need for a SELECT * FROM table WHERE(((date)=#" & dateFromWrkSht & "#));" The date field in the Access table was formated "Short Date". The date from the worksheet was formatted "Short Date"; still the two were not compatable and would not recognize each other. I believe because Time is appended to the date in the worksheet. My workaround was to place this =DATE(YEAR(NOW()),MONTH(NOW()),DAY(NOW())) formula in the cell for date and formatted "Short Date" and now works marvelously! Dick Kusleika January 6, 2006 at 9:42 pm doco: You can use Format(dateFromWrkSht, "yyyy-mm-dd") to