简体   繁体   中英

C# - How to retrieve data from Sybase SQL Anywhere 11?

Platform: visual Studio 2010
Language: C#
Framework: .NET 4.0
Project: Windows Form

So, I am unable to retrieve data yet I'm already connected. I've also tried to connect by using 'Server Explorer' , and It could connect and retrieve data properly without any problem.

Settings on 'Server Explorer'

Connection String: Driver={SQL Anywhere 11};userid=*****;servername=*****;autostop=YES;integrated=NO;filedsn=C:\*****\*****.db.dsn;commlinks='SharedMemory,TCPIP{host=}';compress=NO

Provider: `.NET Framework Data Provider for ODBC`

Now, in my source code, I am using System.Data.Odbc;

Code:

String connString = @"Driver={SQL Anywhere 11};userid=*****;servername=gamca;autostop=YES;integrated=NO;filedsn=C:\*****\*****.db.dsn;debug=NO;disablemultirowfetch=NO;commlinks='SharedMemory,TCPIP{host=}';compress=NO;password=*****";
OdbcConnection myConnection = new OdbcConnection(connString);
commandString = "DELETE from AGENCY";
try {
   using (OdbcCommand cmd = new OdbcCommand(commandString, myConnection)) {
   myConnection.Open();
   cmd.ExecuteNonQuery();
   myConnection.Close();
}

Error: Error [42S02] [Sybase][ODBC Driver][SQL Anywhere]Table 'AGENCY' not found

I've also tried using OleDb and iAnywhere.Data.SQLAnywhere (V2), but no luck, I can't pass through this one error.

Anyone has experienced the same problem?

Any comment is appreciated, Thank you..

This Query runs on Default database (eg Master) Add database name to your ConnString or CommandString as follow:

commandString = "USE MyDatabase DELETE from AGENCY";

Dont forget to replace MyDatabase with your Database name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM