从C#应用程序问题连接到嵌入式FireBird数据库
我似乎在从示例C#应用程序连接到嵌入式FireBird数据库时遇到了问题。这是我得到的从C#应用程序问题连接到嵌入式FireBird数据库,c#,firebird,firebird-.net-provider,C#,Firebird,Firebird .net Provider,我似乎在从示例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 Stri
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;客户端库=fbedded.dll
未找到错误代码335544972的消息
无效转义序列
作为输出
我在谷歌上搜索了335544972错误代码,似乎是关于无效的连接字符串,但我还没有找到任何关于这方面的“官方”信息
有没有人遇到过类似的情况,以便告诉我我做错了什么
谢谢
UPD:
正如所建议的那样,我试图简化我的连接字符串。因此,我使用了
FbConnection Conn = new FbConnection("Database=D:\\tmp\\1\\cafw.fdb;ServerType=1");
它给了我一个信息,“嵌入式Firebird不支持可信身份验证”。因此,我尝试使用常规的sysdba登录
FbConnection Conn = new FbConnection("Database=D:\\tmp\\1\\cafw.fdb;ServerType=1;User=SYSDBA;Password=masterkey");
得到了同样的错误信息。奇怪的东西
很难相信,但我能说出这一点的唯一原因是,我的c#解决方案位于d:…\c#\myAppProject中的某个地方(是的,这都是关于#符号)
在我更换项目后,一切正常。我知道这不是你的答案,但这是给我的,所以 您必须确保提供用户和密码,即使它们不是必需的(任何密码都可以)