这是一个朋友的小项目,其目标是从给定的firebird数据库文件中读取数据并将其放入MS Office 2010模板中......因此Firebird作为数据库后端和.NET 4.x项目类型办公室的东西是给定的堆栈。
我写了一个小型(控制台)测试应用程序来与firebird嵌入式数据库客户端取得联系,并且已经有了第一个我不能解决的问题。我的守则如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FirebirdSql.Data.FirebirdClient;
namespace TestFirebirdConnection
{
class Program
{
static void Main(string[] args)
{
// Set the ServerType to 1 for connect to the embedded server
string connectionString =
"User=sysdba;" +
"Password=******;" +
"Database=C:\\...\\...\\...\\PDATA.FDB;" +
"ServerType=1;" +
"Charset=NONE;";
try
{
FbConnection dbConnection = new FbConnection(connectionString);
dbConnection.Open();
string SQLCommandText = "select * from Patients";
FbCommand dbCommand = new FbCommand(SQLCommandText, dbConnection);
FbDataReader dr = dbCommand.ExecuteReader();
while (dr.Read())
{
Console.WriteLine(dr["TITLE"] + " " + dr["SURNAME"] + " " + dr["NAME"]);
}
dr.Close();
dbConnection.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
一切正常,代码在shell上输出患者数据库的所有名称。我已经使用调试器检查,如果datareader和dbConnection正确关闭(),情况就是如此。
在最后一行之后,每次都会收到一条令人讨厌的Windows错误消息(那种内存访问违规),我无法找到原因。
更新:似乎它与fbintl.dll
有关更新2:如果我连接到firebird服务器(不幸的是,这对我的轻量级办公模板项目来说不是一个好的解决方案),这种情况不会发生。
有人知道为什么会这样吗?
我正在使用:
我实际上不确定创建数据库文件的firebird版本是什么