Program freezes while execute?

Posted on 2000-04-25
Last Modified: 2010-05-02
Hi all,
    I wrote a simple program with only 1 form and a button to update the database in MS SQL 6.5, it is just a simple program using ADO, RDO to read data from a fixed lenght text file and update the record in the SQL server...
    I compiled and run the program and while the program runs I can not minimize it... The form only response when the program  finished running.
    Did I do something wrong or forgot to include anything in the code? When I check the task manager the program shows "not responding" but it is actually running.....
Please help,

PS. I am in the NT environment.
Question by:stephenhoang
LVL 38

Expert Comment

ID: 2749224
If your program is busy, ie. doing some processing task that is keeping the CPU busy, you will suffer a lack of responsiveness in your app.
If you insert an occasional DoEvents statement into a busy loop, then the program will accept messages from the user interface.

DoEvents will make the processing slightly slower, but will allow the program to respond to the mouse, repaint the windows etc.


Expert Comment

ID: 2749225
Use the DoEvents command, this should fix your problem.
LVL 18

Expert Comment

ID: 2749265
Just a couple of thoughts, you should never mix database access methods in the same program, in many cases it will introduce unpredictable behavior.

That said, if you use SQL Servers Bulk Copy program, you'll load the data about 100 times faster.


Copies a database table to or from an operating-system file in a user-specified format.

bcp [[database_name.]owner.]table_name {in | out} datafile [/m maxerrors] [/f formatfile] [/e errfile] [/F firstrow] [/L lastrow] [/b batchsize] [/n] [/c] [/E][/t field_term] [/r row_term] [/i inputfile] [/o outputfile] /U login_id [/P password] [/S servername] [/v] [/a packet_size]



Specifies the database. If the table being copied is in your default database, this parameter is optional.


Is the owner's name. This name is optional if you own the table being copied. This parameter is optional. If no owner is specified and you do not own a table of that name, the program will not execute.


Specifies which database table to copy.

in | out

Specifies the direction of the copy. The in option copies from a file into the database table; the out option copies to a file from the database table.


Is the full path of an operating-system file when copying a table to or from a hard-disk file or a single diskette. The path can have from 1 through 255 characters. When copying a table to or from multiple diskettes, datafile is a drive specifier only (such as A:).

/m maxerrors

Is the maximum number of errors that can occur before the copy is canceled. Each row that cannot be rebuilt by bcp is ignored and counted as one error. If this option is not included, the default is 10.

/f formatfile

Is the full path of a file with stored responses from a previous use of bcp on the same table; creation of the format file is optional. Use this option when you have already created a format file that you want to use when copying in or out. After you answer format questions, bcp asks whether you want to save your answers in a format file. The default filename is BCP.FMT. The bcp utility can refer to a format file when copying data so that you do not have to duplicate your previous format responses interactively. If this option is not used, bcp queries you for format information.

/e errfile

Is the full path of an error file where bcp stores any rows that it was unable to transfer from the file to the database. Error messages from the bcp utility go to the user's workstation. If this option is not used, no error file is created.

/F firstrow

Specifies the number of the first row to copy (the default is the first row).

/L lastrow

Specifies the number of the last row to copy (the default is the last row).

/b batchsize

Specifies the number of rows per batch of data copied (the default copies all the rows in one batch).


Performs the copy operation using the data's native (database) datatypes as the default. This option does not prompt for each field; it uses the default values.


Performs the copy operation with a character datatype as the default. This option does not prompt for each field; it uses char as the default storage type, no prefixes, \t (tab) as the default field separator, and \n (new line) as the default row terminator.


Is used when identity values are present within the table to be imported.
When importing data, an identity column is temporarily assigned an identity value of 0. As the rows are inserted into the table, SQL Server assigns unique values based on the seed and increment values specified during table creation. Use the /E flag when identity values already exist in the file. If SQL Server-generated identity values are preferred, place only non-identity columns in the file.

/t field_term

Is the default field terminator.

/r row_term

Is the default row terminator.

/i inputfile

Is the name of a file that redirects input to bcp.

/o outputfile

Is the name of a file that receives output redirected from bcp.

/U login_id

Is a login ID.

/P password

Is a user-specified password. If this option is not used, bcp prompts for a password. If this option is used at the end of the command line without any password, bcp uses the default password (NULL).

/S servername

Specifies which SQL Server to connect to. The servername is the name of the server computer on the network. This option is required when you are executing bcp from a remote computer on the network.


Reports the current DB-Library version number.

/a packet_size

Is the number of bytes, per network packet, sent to and from the server. A server configuration option can be set using SQL Enterprise Manager (or the sp_configure system stored procedure). However, this option can be overridden on an individual basis with the bcp /a option. The valid values for packet_size are 512 through 65535. The server default is 4096; the default value for the Windows NT - based version of bcp is 4096. The default value for MS-DOS is 512, although larger sizes can be requested.
Increased packet size may enhance performance on bulk copy operations. Microsoft testing indicates that 4096 to 8192 is typically the fastest setting for bulk copy operations. If a larger packet is requested but cannot be granted, the client will default to 512. The performance statistics generated at the end of a bcp run will show the actual packet size used.
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now


Expert Comment

ID: 2749278
DoEvents will only help with processing being done by your application. That's to say that if you have a very large loop,for example. If you are querying the database (or some other task that passes control to the databse), DoEvents will not help you. What you should look into would be Threading the database stuff, freeing up processor time for your application. Unfortunately, I do not know how you can thread in VB, but I do recall attending a seminar at VBITS where the speaker said it can be done. You might want to check the M$ Knowledgebase on the subject.

Good luck!!
LVL 18

Expert Comment

ID: 2749287
See this question for more discussion on bcp or on using an even faster method with DTS

Accepted Solution

nicehumanbeing earned 50 total points
ID: 2750162
with RDOs in case u want to display a status / check out things, u can add it in a small loop like...

do while rdoResultset.StillExecuting
  .. do something / display status etc.

You can use DoEvents to make your program yield to other events as well. that will allow it to respong to user event. But If a DoEvents is called from within another, the results are unpredictable... so be careful


Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Getting warning: You are about to delete 1 row(s) 9 54
TT Auto Dashboard 13 101
Macro Excel - Multiple If conditions 2 88
Formula problem with Excel attachment 6 43
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question