<?xml version="1.0" encoding="utf-8" ?>
- <arrayofstring xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://WebService/">
<string>System.Data.Odbc.OdbcException (0x80131937): ERROR [08001] [Sybase][ODBC Driver][SQL Anywhere]未找到数据库服务器(not found database) 在 System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) 在 System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions) 在 System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) 在 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) 在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource I was able to connect to the database at the time of the VS2012 test, but when I deployed on IIS, he didn't find the database server |
I have solved the problem, the reason is my connection string is mistake. this is my connection string: host=192.168.1.237;Data Source=mm;Driver={SQL Anywhere 12};UID=dba;PWD=sql; thanks Everyone |
Can you please give us the connection string that you are using?
What is the URL of the web service? (e.g. does it have the server name, or uses "localhost"?
I am not sure that it has anything related to the Trust, but just in case, please be sure that your application uses Full Trust.
file : ---Web.config ---
<connectionstrings> <add name="conn" connectionstring="server=192.168.1.237;database=star;uid=dba;password=sql" providername="iAnywhere.Data.SQLAnywhere.v3.5"/>
---test.asmx.cs---
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Data.Odbc; using System.Data; using System.Data.SqlClient; using iAnywhere.Data.SQLAnywhere; using System.Web.Extensions; using System.Web.Script.Serialization; using System.Text.RegularExpressions; using System.Text; namespace WebService1 { /// <summary> /// Service1
/// </summary> [WebService(Namespace = "http://WebService/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] [System.Web.Script.Services.ScriptService] public class Service1 : System.Web.Services.WebService { [WebMethod] public List<string> result(String tb_name,String command) { return test(tb_name, command, return_str(tb_name)); //return test("part", "part_id='0011'", return_str("part")); } private List<string> test(String str_tb_name,String command,List<string> tb_name) {
list.Add(MyLogDataReader[count].ToString());
private List<string> return_str(String str_tb_name) { List<string> lists = new List<string>(); String strOdbcConn = "ODBC;Driver=Sybase SQL Anywhere 5.0;DefaultDir=C:\DatabasePath\;Dbf=C:\SqlAnyWhere50\MyDatabase.db;Uid=dba;Pwd=MyPassword;Dsn=\"\";"; OdbcConnection oLogConn; OdbcCommand oLogCmd; String strSql = "SELECT * FROM pbcatcol where pbc_tnam='" + str_tb_name + "'"; //name try { oLogConn = new OdbcConnection(strOdbcConn); oLogCmd = new OdbcCommand(strSql, oLogConn); oLogConn.Open(); OdbcDataReader MyLogDataReader = oLogCmd.ExecuteReader(CommandBehavior.CloseConnection); while (MyLogDataReader.Read()) { lists.Add(MyLogDataReader[3].ToString()); //clomn } return lists; } catch (Exception ex) { lists.Add("ERROR2"); return lists; } finally {
}
The connection string appears to be malformed.
Server is the SA database server name not the machine host name or IP where the SA database server is running.
Lets assume that you start a database server on a machine with the IP 192.168.1.237 as follows:
dbsrv17 -n MyServer -x tcpip databasefile.db -n MyDatabase
The connection string would look like:
Links=TCPIP{host=192.168.1.237};Server=MyServer;DatabaseName=MyDatabase;uid=dba;pwd=sql
It is a bit confusing to see a reference to the SQL Anywhere .NET iAnywhere.Data.SQLAnywhere.v3.5 provider in the context of the ODBC driver, not to mention that the ODBC driver referenced in one spot appears to be from SQL Anywhere 5 (Driver=Sybase SQL Anywhere 5.0) and also from SQL Anywhere 12 (Driver={SQL Anywhere 12}). What version of the SQL Anywhere client software are you really using? And server software?