问题
This is a small project for a friend where the goal is to read data from a given firebird database file and put it into MS Office 2010 Templates...so both Firebird as a database backend and .NET 4.x project type office something is the given stack.
I wrote a small (console) test app to get in touch with the firebird embedded database client, and already have the first issue I don't get rid of. My Code is as follows:
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);
}
}
}
}
All works fine, the code puts out all names of a patients database on the shell. I already used the debugger to check, if the datareader and the dbConnection is closed() properly, which is the case.
After the very last line I get a nasty Windows Error Message (that kind of memory access violation) every time, where I can't find out why this is happening.
UPDATE: It seems, that it has to do with fbintl.dll
UPDATE 2: This does not happen, if I connect to a firebird server (which is unfortunately not a good solution for my light weight office template project)
Anybody knows why this is happening?
I am using:
- Firebird ADO.NET Provider 4.6 (from NuGet)
- Firebird Embedded database 2.5.3 x64
I actually am not sure with which version of firebird the database file was created
来源:https://stackoverflow.com/questions/28775097/net-console-app-with-firebird-client-crashes-on-program-end