Hey there... I think I may have found a possible problem within the SQL portion of my VB.Net 2008 app. Yet, I'm kinda new to this. On the "MessageBox.Show(ex.Message)" line I receive the SQL error that reads: Incorrect syntax near the keyword 'Statistics'. Therefor it says the line where i put: WHAT IS WRONG WITH THIS LINE? However, please note that I used a continuation underscore on this line. Thanks a lot! ---- Here's the procedure.... Friend Sub SaveToSQL() Dim ConnectionString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename= ...; User Instance=True" Dim SQL_Connection As New SqlClient.SqlConnection(ConnectionString) SQL_Connection.Open() ' I need to redo the connection string! Dim SQL_Command As New SqlClient.SqlCommand("INSERT INTO Statistics VALUES (?, ?)", _ SQL_Connection) <------------------------------------------------ WHAT IS WRONG WITH THIS LINE? For L_Index = 1 To (G_NIP - G_MissingStock) For L_Day = 1 To G_MaxSampleSize G_StockIndex += 1 SQL_Command.Parameters.Add(New SqlClient.SqlParameter("StockIndex", G_StockIndex)) Try SQL_Command.ExecuteNonQuery() Catch ex As Exception MessageBox.Show(ex.Message) <---- Here's where the error is shown! End Try Next L_Day Next L_Index ' @@@@ Both of these two values NEED to be verified! SQL_Connection.Close() SQL_Connection.Dispose() End Sub ---- May you have a blessed day as the Lord wills. JEP_Dude
I think your query may be using a reserved word - try this instead INSERT INTO [Statistics] VALUES (?, ?)
Dear Sir .... Thanks for your reply! Yet my SQL experience is so limited that I must ask for you to further explain what you mean when you said, "tics and quotes". Otherwise, I'm at a loss. May you and everyone else have a blessed day. JEP_Dude
If you ever have a SQL statement containing the single quote (') (a.k.a., apostrophe or "tick" mark) or double quote ("), SQL Server can interpret them incorrectly unless you escape them. These two links should help you: SQL Server Documentation on SET QUOTED_IDENTIFIER How to Escape Single Quotes