Solved

Program freezes while execute?

Posted on 2000-04-25
6
217 Views
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,
Steve.

PS. I am in the NT environment.
0
Comment
Question by:stephenhoang
6 Comments
 
LVL 38

Expert Comment

by:PaulHews
Comment Utility
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.

0
 
LVL 2

Expert Comment

by:Sage020999
Comment Utility
Use the DoEvents command, this should fix your problem.
0
 
LVL 18

Expert Comment

by:mdougan
Comment Utility
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.

BCP

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

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]

where

database_name

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

owner

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.

table_name

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.

datafile

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).

/n

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.

/c

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.

/E

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.

/v

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.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 6

Expert Comment

by:DrDelphi
Comment Utility
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!!
0
 
LVL 18

Expert Comment

by:mdougan
Comment Utility
See this question for more discussion on bcp or on using an even faster method with DTS

http://www1.experts-exchange.com/bin/Q.10296614
0
 

Accepted Solution

by:
nicehumanbeing earned 50 total points
Comment Utility
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.
loop

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

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now