<?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, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) 在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) 在 System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) 在 System.Data.Odbc.OdbcConnection.Open() 在 WebService1.Service1.test(String str_tb_name, String command, List`1 tb_name)</string> </arrayofstring>

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

asked 16 Jan, 01:02

mfkpie8's gravatar image

mfkpie8
85424852
accept rate: 10%

1

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.

(16 Jan, 04:58) Vlad
Replies hidden

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"/>

</connectionStrings>

---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<String> list = new List<String>();
        List<String> list_result = new List<String>();
        string strOdbcConn = "Driver={SQL Anywhere 12};SERVER=mm;DBN=star;UID=dba;PWD=MyPassword";

        OdbcConnection oLogConn;
        OdbcCommand oLogCmd;
        String strSql = "";
        if (command != "")
        {
            strSql = "SELECT * FROM " + str_tb_name + " WHERE " + command;
        }
        else { 
            strSql = "SELECT * FROM " + str_tb_name;
        }


        try
        {
            oLogConn = new OdbcConnection(strOdbcConn);
            oLogCmd = new OdbcCommand(strSql, oLogConn);
            oLogConn.Open();
            OdbcDataReader MyLogDataReader = oLogCmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (MyLogDataReader.Read())
            {
                int count = 0;
                while (count < MyLogDataReader.FieldCount - 1)
                {

list.Add(MyLogDataReader[count].ToString());

                    count++;
                }
                for (int i=0; i < list.Count - 1; i++) {      //to
                    list_result.Add(tb_name[i] + ":" + list[i]);
                }
                list.Clear();

            }
            return list_result;
        }
        catch (Exception ex)
        {
            Console.Write(ex);
            list.Add(ex.ToString());
            return list;
        }
    }

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 {

        }
    }
}

}

(16 Jan, 08:03) mfkpie8
2

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

(16 Jan, 08:49) Chris Keating
1

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?

(16 Jan, 09:41) JBSchueler
Comment Text Removed

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

permanent link

answered 16 Jan, 22:49

mfkpie8's gravatar image

mfkpie8
85424852
accept rate: 10%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×56

question asked: 16 Jan, 01:02

question was seen: 228 times

last updated: 18 Jan, 17:09