• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Program freezes while execute?

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.
1 Solution
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.

Use the DoEvents command, this should fix your problem.
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.
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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!!
See this question for more discussion on bcp or on using an even faster method with DTS

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now