Jet 4.0 与 C# Windows 应用程序的连接问题

发布于 2024-09-13 00:31:17 字数 479 浏览 1 评论 0原文

我正在开发一个在服务器计算机上连续运行的 win .net 应用程序。应用程序将使用 Jet 4.0 OLEDB 提供程序与驻留在多台客户端计算机上的 access(mdb) 数据库连接。

每个连接的数据库已被本地安装的其他一些应用程序使用。

当客户端计算机始终处于活动状态时,我的应用程序可以成功与所有数据库进行通信。

但是,如果我的一台客户端计算机出现故障(例如系统或网络)并重新启动,应用程序将无法重新连接到该特定数据库,尽管可以通过网络访问它。

即使我尝试以编程方式重新启动我的应用程序以重新建立连接。但是,它也失败了。

应用程序只是抛出

“磁盘或网络错误”

“未指定错误”

“无法启动您的应用程序。工作组信息文件丢失或由其他用户独占打开”

有人吗?

I am developing a win .net application which runs continuously in server machine. Application will get connected with access(mdb) databases resided in several client machines using Jet 4.0 OLEDB provider.

Each connected database was already in use by some other application installed locally.

My app successfully communicates with all the databases when client machines are constantly alive.

But if one of my client machine goes down(say system or network) and rebooted, application cannot reconnect to that specific database, though it is accessible via network.

Even i tried to restart my application programmatically to re-establish the connection. But, It also fails.

Application just throws

"Disk or Network error"

or

"Unspecified Error"

or

"Cannot start your application. The workgroup information file is missing or opened exclusively by another user."

Anyone?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏至、离别 2024-09-20 00:31:17

是的。

实际上,我对与应用程序关联的每个数据库使用静态对象和以下代码段。

DbProviderFactory factory;
DbConnection connection;
DbDataAdapter dataAdapter;

void SetConnection(ConnectionStringSettings settings) {
    factory = DbProviderFactories.GetFactory(settings.ProviderName);
    if (factory != null) {
        if (connection == null) {
            connection = factory.CreateConnection();
            dataAdapter = factory.CreateDataAdapter();                    
            connection.ConnectionString = settings.ConnectionString;
        }
    }
}

public DataTable GetTable(string statement) {
    DataTable dataTable = null;
    if (connection != null) {
       dataAdapter.SelectCommand = connection.CreateCommand();
       dataAdapter.SelectCommand.CommandText = statement;
       dataTable = new DataTable();
       dataAdapter.Fill(dataTable);
    }
    else
       throw new Exception("Connection object null");

    return dataTable;
}

我正在从 app.config 设置连接字符串和提供程序名称。

Yes.

Actually, I'm using static object with the following piece of code for each of the databases associated with the application.

DbProviderFactory factory;
DbConnection connection;
DbDataAdapter dataAdapter;

void SetConnection(ConnectionStringSettings settings) {
    factory = DbProviderFactories.GetFactory(settings.ProviderName);
    if (factory != null) {
        if (connection == null) {
            connection = factory.CreateConnection();
            dataAdapter = factory.CreateDataAdapter();                    
            connection.ConnectionString = settings.ConnectionString;
        }
    }
}

public DataTable GetTable(string statement) {
    DataTable dataTable = null;
    if (connection != null) {
       dataAdapter.SelectCommand = connection.CreateCommand();
       dataAdapter.SelectCommand.CommandText = statement;
       dataTable = new DataTable();
       dataAdapter.Fill(dataTable);
    }
    else
       throw new Exception("Connection object null");

    return dataTable;
}

I am setting the connection string and provider name from the app.config.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文