EDN Admin
Well-known member
Hello everyone Iam trying to execute SQL Query of select statement and output to file command using c# ODBC object on Sybase db but some it doesnt work and throws up the exception :
ERROR [42000] [Sybase][ODBC Driver][SQL Anywhere]Syntax error near Output on line 1
<div style="color:black; background-color:white
<pre> <span style="color:blue private <span style="color:blue static <span style="color:blue void ExcecuteSelectQuery(<span style="color:blue string Version)
{
<span style="color:blue string connstring = <span style="color:#a31515 "Dsn=GlobeCrewKiosk;uid=dba;pwd=sql";
<span style="color:blue using (OdbcConnection conn = <span style="color:blue new OdbcConnection(connstring))
{
conn.Open();
OdbcCommand DbCommand = conn.CreateCommand();
DbCommand.CommandText = <span style="color:#a31515 "select * from GCK_KioskSetupOptions; Output to "+<span style="color:#a31515 ""+<span style="color:#a31515 "C:\KSO.csv"+<span style="color:#a31515 ""+<span style="color:#a31515 " FORMAT TEXT DELIMITED BY /t QUOTE ;";
DbCommand.ExecuteScalar();
conn.Close();
}
}
[/code]
Command text value in debug mode:
<pre lang="x-c# "select * from GCK_KioskSetupOptions; Output to C:\KSO.csv FORMAT TEXT DELIMITED BY /t QUOTE ;"
[/code]
When I copied the command text and removed the double quotes around it and ran on sybase database using sybase management tools(Interactive SQL) i have no issues.
Any ideas to resolve this error.
Thank you
<
Ram<br/>
View the full article
ERROR [42000] [Sybase][ODBC Driver][SQL Anywhere]Syntax error near Output on line 1
<div style="color:black; background-color:white
<pre> <span style="color:blue private <span style="color:blue static <span style="color:blue void ExcecuteSelectQuery(<span style="color:blue string Version)
{
<span style="color:blue string connstring = <span style="color:#a31515 "Dsn=GlobeCrewKiosk;uid=dba;pwd=sql";
<span style="color:blue using (OdbcConnection conn = <span style="color:blue new OdbcConnection(connstring))
{
conn.Open();
OdbcCommand DbCommand = conn.CreateCommand();
DbCommand.CommandText = <span style="color:#a31515 "select * from GCK_KioskSetupOptions; Output to "+<span style="color:#a31515 ""+<span style="color:#a31515 "C:\KSO.csv"+<span style="color:#a31515 ""+<span style="color:#a31515 " FORMAT TEXT DELIMITED BY /t QUOTE ;";
DbCommand.ExecuteScalar();
conn.Close();
}
}
[/code]
Command text value in debug mode:
<pre lang="x-c# "select * from GCK_KioskSetupOptions; Output to C:\KSO.csv FORMAT TEXT DELIMITED BY /t QUOTE ;"
[/code]
When I copied the command text and removed the double quotes around it and ran on sybase database using sybase management tools(Interactive SQL) i have no issues.
Any ideas to resolve this error.
Thank you
<
Ram<br/>
View the full article