Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,
I am trying to connect Sybase database using C# from Visual studio.
But I'm getting this error after around 30 seconds -
HTML
ERROR [00000] [Sybase][ODBC Driver]The command has timed out.

Actually it requires 1 minutes 18 seconds to execute the query in Sybase.
This is my full code:
C#
System.Data.Odbc.OdbcConnection con = 
     new System.Data.Odbc.OdbcConnection("connStr");
                con.ConnectionTimeout = 300;
                System.Data.Odbc.OdbcCommand com = 
     new System.Data.Odbc.OdbcCommand("query", con);
                System.Data.Odbc.OdbcDataAdapter adapter = 
     new System.Data.Odbc.OdbcDataAdapter(com);
                System.Data.DataTable dt = new System.Data.DataTable();
                adapter.Fill(dt)

Please help me ASAP.
Thank you in advance.
Posted
Updated 29-Jun-16 18:31pm
v3
Comments
V. 28-May-13 8:12am    
are you sending the string "connStr" to the connection and the string "query" to the command? That doesn't look right...
Member 9330747 29-May-13 7:24am    
No, I'm using connection string as
string connStr = "DSN=" + dsn + "; Uid=" + userId + "; Pwd=" + dePassword + "; Database=" + database;
and
query as "Select top 10 * from Emp_Stg"

The default timeout for OdbcCommand is 30 seconds so you will need to override it.
See http://msdn.microsoft.com/en-us/library/system.data.odbc.odbccommand.commandtimeout.aspx[^]
 
Share this answer
 
i've solved myself. thank you all.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900