.NET接続文字列を使用してSQL Anywhere 12データベースに接続するのは本当に苦労しています。.NET接続文字列を使用してリモートSQL Anywhere 12データベースに接続
私は、次のクエリ文字列を使用しています:
Data Source=xxx.xxx.xxx.xxx,yyyy; Initial Catalog={MyDatabaseName}; User ID={MyUsername}; Password={MyPassword}
I(xxx.xxx.xxx.xxxは=リモートサーバとYYYYのIPアドレスが必要なポートがある場合)私は次のエラーを受信しています、これを実行すると、しかし
private const string connectionString = "{MyQueryString}";
private const string testQuery = "{ATestSelectQuery}";
using (SqlConnection conn = new SqlConnection(connectionString))
{
ExecuteNonQuery(conn, testQuery);
}
static void ExecuteNonQuery(SqlConnection conn, string query)
{
try
{
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.CommandText = query;
cmd.CommandType = CommandType.Text;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
catch (Exception ex)
{
Console.WriteLine("ERROR: {0}", ex.Message);
}
}
:私の接続をテストするには、次のコードでこれを実行しようとしている
ERROR: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)