我正在使用嵌入在我的 .net 应用程序中的 FireBird。这个家伙是我的联系人:
代码是:
public class ImDb{
private static FbConnection _fbConnection;
public static FbConnection IMManagerConnection() {
var fbConnStringBuilder = new FbConnectionStringBuilder();
fbConnStringBuilder.ServerType = FbServerType.Embedded;
fbConnStringBuilder.UserID = "sysdba";
fbConnStringBuilder.Password = "masterkey";
//fbConnStringBuilder.ClientLibrary = @"fbembed.dll";
fbConnStringBuilder.Database = @"IMMANAGER.FDB";
_fbConnection = new FbConnection(fbConnStringBuilder.ConnectionString);
return _fbConnection;
}
}
这是我的测试用例:
代码是:
[Test]
public void SimSymbolTest(){
FbConnection fbc=IMManager.Common.ImDb.IMManagerConnection();
fbc.Open();
Console.WriteLine("The Server Version is :" + fbc.ServerVersion);
Console.WriteLine("The database is :" + fbc.Database);
Console.WriteLine("The DataSource is :" + fbc.DataSource);
Console.WriteLine("The Version Number is: " + fbc.ServerVersionNumber);
fbc.Close();
}
在我的应用程序中,这是错误的!!报告不要加载 fbembed.dll
代码是:
private DataTable ExeQuery(string sqlString){
DataSet ds = new DataSet();
FbConnection fbc = ImDb.IMManagerConnection();
try {
fbc.Open();
FbTransaction fbt = fbc.BeginTransaction();
FbCommand fbcmd = new FbCommand(sqlString, fbc, fbt);
FbDataAdapter fbda = new FbDataAdapter(fbcmd);
fbda.Fill(ds);
fbt.Commit();
} catch (Exception ex) {
MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
} finally {
fbc.Close();
}
return ds.Tables[0];
}
这是我的目录:
请帮帮我!在此先感谢!
然后我修改连接代码,添加ClientLibrary的值:
测试用例运行正常!
但是在应用程序中,错误再次发生。