简体   繁体   English

与普及数据库的连接速度很慢

[英]connection to Pervasive database slow

This has been an on going issue at my place of work. 在我的工作地点,这一直是一个持续的问题。 Previously, we had a co-op programming student write us some applications using C# which ran well on his laptop, but once the applications were put to use on different computers, the connection to the pervasive database because painfully slow. 以前,我们的一位合作编程学生使用C#编写了一些可以在他的笔记本电脑上很好地运行的应用程序,但是一旦将这些应用程序用于不同的计算机上,由于痛苦的速度很慢,因此无法连接到普及的数据库。

Now I am writing a simple VB.net application which need to query the Pervasive database, and I'm running into the same issue. 现在,我正在编写一个简单的VB.net应用程序,该应用程序需要查询Pervasive数据库,并且遇到了同样的问题。

here's my code: 这是我的代码:

 'PSQL variables
        Dim myPsqlConnection As PsqlConnection = New PsqlConnection("ServerName=FILESERVER;ServerDSN=SAGE2")
        Dim queryString As String
        queryString = "SELECT NAME FROM CUSTOMER"
        Dim MyCommand As New PsqlCommand(queryString, myPsqlConnection)
        Dim MyReader As PsqlDataReader
        Dim tempCustname As String


        Try 'open conncetion to Pervasive DB
            myPsqlConnection.Open()
        Catch ex As Exception
            MsgBox("COULD NOT OPEN A CONNECTION TO THE DATABASE" & vbCrLf & ex.Message)
            Exit Sub
        End Try

        Try 'execute Pervasive query
            MyReader = MyCommand.ExecuteReader
        Catch ex As Exception
            MsgBox("QUERY ERROR" & vbCrLf & ex.Message)
            Exit Sub
        End Try
        If MyReader.HasRows = False Then
            MsgBox("NO RESULTS FOUND")
            Exit Sub
        End If
        While (MyReader.Read)
            tempCustname = MyReader("NAME").ToString()
            Customers.Items.Add(tempCustname)
        End While
        MyReader.Close()
        myPsqlConnection.Close()

I stepped through the program and it take about 30 seconds to get past the line where it opens the connection. 我逐步执行了该程序,大约需要30秒才能通过打开连接的那一行。

As for the specs (I'll do my best): 至于规格(我会尽力):

My computer is quite powerful (16 gb or ram, 6 core AMD processor at 3.0 Ghz per core, windows 7 home 64 bit) 我的计算机功能非常强大(16 gb或ram,6核AMD处理器,每核3.0 GHz,Windows 7家庭版64位)

Pervasive.Data.SqlClient Version 3.2 Pervasive.Data.SqlClient版本3.2

Compiling with Microsoft Visual Basic 2010 Express 使用Microsoft Visual Basic 2010 Express进行编译

There are very few computers on this network (about 7), and I have no such trouble with MS Access databases. 该网络上的计算机很少(大约7台),并且MS Access数据库没有这种麻烦。 Our server is new 2 years ago, and out network has been upgraded to a GB connection. 我们的服务器是2年前的新服务器,出网已升级到GB连接。 I should note I know very little about databases in general, let alone connecting with VB. 我应该注意,我一般对数据库了解甚少,更不用说与VB连接了。 I'm not really the best person to be doing this, but I'm still the most qualified person in our small company. 我并不是做到这一点的最佳人选,但我仍然是我们小公司中最有资格的人。

I've got it working now. 我现在可以正常工作了。 The solution was to first install the database in the pervasive control center. 解决方案是首先在普及控制中心中安装数据库。 First by selecting "new database" from the main window of the PCC and filling in the database name, location, username and password. 首先,从PCC的主窗口中选择“新数据库”,然后填写数据库名称,位置,用户名和密码。

Next I changed the connection from pervasive ADO to OLEDB. 接下来,我将连接从普遍的ADO更改为OLEDB。 My connection string now looks like this: 现在,我的连接字符串如下所示:

Dim myPsqlConnection As OleDbConnection = New OleDbConnection("Provider=PervasiveOLEDB;Data Source=DatabaseName;Location=FILESERVER")

Thanks to all everyone for your help! 感谢所有人的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM