| | |
Program loses response during large DB queries VB.NET
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: May 2008
Posts: 15
Reputation:
Solved Threads: 2
Hi,
When I execute queries which have a lot of data returned in the recordset my VB app seems to hang (IE: This program is not responding)
I'm using ODBC to connect to the database and am using Postgres DB
I'm not sure that there is a way to sort this out, I hope there is?
Thanks all!
When I execute queries which have a lot of data returned in the recordset my VB app seems to hang (IE: This program is not responding)
I'm using ODBC to connect to the database and am using Postgres DB
VB.NET Syntax (Toggle Plain Text)
Public db_name As String Public db_username As String Public db_userpassword As String Public db_server As String Public connStr As String Public sqlCommand As OdbcCommand Public sqlConn As OdbcConnection Public Rs As OdbcDataReader Public Sub DoQuery(ByVal tmpSQL as String) connStr = "Driver={PostgreSQL ANSI};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword sqlCommand = New OdbcCommand sqlConn = New OdbcConnection(connStr) If sqlConn.State = ConnectionState.Closed Then sqlConn.Open() End If sqlCommand.CommandType = CommandType.Text sqlCommand.Connection = sqlConn sqlCommand.CommandText = tmpSQL Rs = sqlCommand.ExecuteReader End Sub
I'm not sure that there is a way to sort this out, I hope there is?
Thanks all!
•
•
Join Date: Jun 2006
Posts: 45
Reputation:
Solved Threads: 3
I would try to limit the amount of data for each query.
Using the reader in order to populate some kind of repository do take a long time.
The way the reader works is that it only reads one line of data at a time.
Ie:
However, if you limit the amount of data to read with a WHERE clause this will go faster.
Or, you could use a dataadapter/dataset and basically get a mirror copy of the data.
Then you can search and select from there.
The CommandBuilder is used to automatically create INSERT/DELETE/UPDATE queries when you need to update, insert or delete information in the database. Good thing to use if you don't want to create long and complicated queries manually.
Using the reader in order to populate some kind of repository do take a long time.
The way the reader works is that it only reads one line of data at a time.
Ie:
VB.NET Syntax (Toggle Plain Text)
While Rs.Read If Not IsDBNull(Rs.Item("some_column_name")) Then repository = Rs.Item("some_column_name") End While
Or, you could use a dataadapter/dataset and basically get a mirror copy of the data.
Then you can search and select from there.
VB.NET Syntax (Toggle Plain Text)
Public db_name As String Public db_username As String Public db_userpassword As String Public db_server As String Public connStr As String Public sqlCommand As OdbcCommand Public sqlConn As OdbcConnection Public Rs As OdbcDataReader '''Remove this Public Da as OdbcDataAdapter '''Replace with this Public sqlComBuilder as OdbcCommandBuilder '''Add this Public Ds As DataSet '''Add this too Public Sub DoQuery(ByVal tmpSQL as String) connStr = "Driver={PostgreSQL ANSI};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword sqlConn = New OdbcConnection(connStr) Da = New OdbcDataAdapter(tmpSQL, sqlConn) sqlComBuilder = New OdbcCommandBuilder(Da) Ds = New DataSet() sqlConn.Open() Da.Fill(Ds,"name_of_table") sqlConn.Close() End Sub
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Converting from C# .NET 1.0 to VB.NET 2.0
- Next Thread: Disable user to change tab
| Thread Tools | Search this Thread |
.net .net2008 2008 access add advanced application array basic beginner browser button buttons center click code combo cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic employees excel exists fade filter forms generatetags html images input intel internet listview map mobile module monitor msaccess mysql net number objects open pan panel pdf picturebox picturebox2 port position print printing printpreview problem regex reuse right-to-left save search searchvb.net serial settings shutdown socket sqldatbase sqlserver storedprocedure survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winforms wpf wrapingcode xml year





