3

サンプルのC#アプリから組み込みのFireBirdデータベースに接続する際に問題が発生したようです。これが私が持っているものです。

static void Main(string[] args)
    {

        //Some constant parameters used to form up the connection string... 
        #region constant literals
        const String User = "SYSDBA";
        const String Password = "masterkey";
        const String DBPath = "D:\\!tmp\\1\\cafw.fdb";
        const String DLLPath = @"fbembed.dll";
        const String Charset = "WIN1251";
        const int Dialect = 3;
        #endregion

        //I check whether we actually have a database file nearby
        //and fbembed.dll. If we don't - we leave
        if (File.Exists(DBPath) == true && File.Exists(DLLPath) == true)
        {
            //I form up a connection string out of literals I've declared above
            FbConnectionStringBuilder CStr = new FbConnectionStringBuilder();

            CStr.ServerType = FbServerType.Embedded;                
            CStr.UserID = User;
            CStr.Password = Password;                
            CStr.Dialect = Dialect;                
            CStr.Database = DBPath;
            CStr.Charset = Charset;                                
            CStr.ClientLibrary = DLLPath;

            //And then I finally try to connect
            FbConnection Conn = new FbConnection(CStr.ToString());                

            try
            {
                //See what we've got in the end
                Console.WriteLine(CStr.ToString());
                //And try to connect
                Conn.Open();
            }
            catch (Exception Ex)
            {
                //Show me what has gone wrong
                Console.WriteLine("\n" + Ex.Message.ToString());
                Console.ReadKey();
            }
            finally
            {
                Conn.Close();
            }
        }
    }

問題は、それは私に

サーバータイプ=埋め込み;ユーザーID=SYSDBA;パスワード=マスターキー;方言=3;初期カタログ=D:!tmp \ 1\cafw.fdb;文字セット=WIN1251;クライアントライブラリ=fbembed.dll

エラーコード335544972のメッセージが見つかりません。

無効なエスケープシーケンス

出力として。

335544972のエラーコードをグーグルで調べたところ、無効な接続文字列に関するもののようですが、それに関する「公式」情報は見つかりませんでした。

誰かが似たようなものに遭遇したので、私が間違っていることを教えてくれませんか?

ありがとう。

UPD:アドバイスされているように、接続文字列を単純化しようとしました。だから、私が上で行われたことの代わりに私は使用しました

FbConnection Conn = new FbConnection("Database=D:\\tmp\\1\\cafw.fdb;ServerType=1");

「TrustedAuthはEmbeddedFirebirdではサポートされていません」というメッセージが表示されました。だから、私は通常のsysdbaログインを使用しようとしました

FbConnection Conn = new FbConnection("Database=D:\\tmp\\1\\cafw.fdb;ServerType=1;User=SYSDBA;Password=masterkey");

まったく同じエラーメッセージが表示されました。

4

2 に答える 2

5

奇妙なもの。

信じがたいことですが、これに名前を付けることができる唯一の理由は、私のc#ソリューションがd:...... \ c#\ myAppProjectのどこかにあることです(ええ、それはすべて#記号に関するものです)。

プロジェクトを置き換えた後、すべてが正しく機能しました。

于 2010-04-19T17:16:08.923 に答える
2

私はこれがあなたの答えではないことを知っていますが、それは私のためでした。

ユーザーとパスワードは必須ではありませんが、必ず指定する必要があります(どのパスワードでもかまいません)。

于 2012-02-08T06:21:54.793 に答える