0
Good evening, I have a problem running an sql command through an ASP application.
This is the command:
strSql = " INSERT INTO movimento_tef_nsu ( "&_
" identificador "&_
" ,nsu_sitef "&_
" ,valor "&_
" ,ordem_cartao "&_
" ,data_hora "&_
" ,texto_comprovante "&_
" ) "&_
" VALUES ( "&_
" '" & objJSON.data("identificador") & "' "&_
" ," & this.item("nsu") &_
" ," & this.item("valor") &_
" ," & this.item("ordem_cartao") &_
" ,'" & this.item("data_hora") & "' " &_
" ,LEFT('" & this.item("texto_comprovante") & "', 255) "&_
" ) "
I have already checked that the values (which are coming via JSON) are correct because I write to a Log before executing the command.
The error that occurs is as follows:
"An unspecified error occurred! Microsoft OLE DB Provider for SQL Server, error '80040e14'. Syntax error or access Violation"
I also checked that the values are coming according to the type and size of the fields in the database, so much so that if I take the query that is in the log and run in sql management, it works normally.
Does anyone have a hint of what this mistake might be?
Do you happen to have a simple quotation mark on
texto_comprovante
? You can post the final SQL string generated by ASP?– bfavaretto
should not close quotes after "& this.item("nsu")... ?
– Dante
Try to get the generated SQL and try to run directly on the Database. But I would look at this "255" it looks "loose"
– Motta
@Dante, not that line is correct. If the OP can run this query in the SMS then the problem is in the assembly of the "string" or the connection. Make sure you are connected to the correct base. Try, instead of "buildar" the string, a simple Insert/update query
– jean
Guys, I followed what @jean said and I checked that the Connection object was not set at the correct base (somehow lost the setting midway).
– Maturano