Visual Basic Tips #25


----------------------------------------------

TipWorld - http://www.tipworld.com
The Internet's #1 Source for Computer Tips, News, and Gossip

Proudly presents:
Visual Basic

----------------------------------------------


*1. COMPARING DATE VALUES IN SQL SERVER                   
          
If you are comparing dates within SQL Server, you may get some 
unexpected results if you don't remember that every date value 
contains both date and time components. For instance,  

6-19-2000 

is not the same as 

6-19-2000 7:00 PM 

because any date without a time is given a time of 00:00:00. If you do 
need to compare dates, you can use any number of functions to compare 
month, day, and year. You can also convert both dates to text using 
the CONVERT function and then compare just the date portion.


*2. ADO 2.5                   
          
ADO 2.5 is included with Windows 2000 and is also available as a 
separate download from the Microsoft Data Access site. If you go into 
your Program Files\Common Files\System\ADO directory, you'll find a 
bunch of files, some of which have version numbers in the filenames. 
However, there aren't any with the version number 2.5. In fact, ADO 
2.5 is stored in MSADO15.DLL. If you bring up the properties for this 
library (or any other DLL file), you'll be able to see the version 
number stored in the library file itself. 

Microsoft Universal Data Access 
http://www.microsoft.com/data/


*3. UPDATING DATABASES                   
          
If you're writing applications to update your database with either new 
or modified records, you've got several options with ADO. For 
starters, you can create a dynamic recordset, which allows you to add 
new records or update existing ones. You can also create SQL 
statements to perform inserts, updates, and deletes and use the 
Execute method of the Connection object to fire them off. You can even 
create stored procedures with parameters and use them with the Command 
object.  

The fastest way to run your SQL is through stored procedures. All of 
the SQL statements can benefit by being saved as stored procedures. 
Saving the stored procedure also saves the execution plan--which, for 
inserts and updates, includes how to update any indexes related to the 
tables.  

If you don't have the ability to create stored procedures, executing 
SQL statements is the next fastest way to make this work. The system 
does have to create the execution plan on the fly; however, this 
doesn't take nearly as long as does opening a dynamic recordset and 
making updates.


*4. FREE VB NEWSLETTER AT ABOUT.COM                   
          
You can sign up for a free Visual Basic newsletter at About.com. 
Specifically, you can expect to be kept abreast of (in its words) 
"news and views from Visual Basic." 

Here's the URL: 

http://visualbasic.about.com/compute/visualbasic/gi/pages/mmail.htm


*5. USING MULTISELECT LIST BOXES                   
          
VBExplorer.com has recently run an article about working with 
multiselect list boxes. Written by John Smiley, this article provides 
some good information to help you get the most from list boxes--and it 
is worth the visit. 

MultiSelect ListBoxes 
http://www.vbexplorer.com/vb_feature/june2000/june2000.asp


*6. BUILDING A PERCENTAGE BAR                   
          
A user asked me recently if it was possible to build a bar graph, such 
as the ones used in most installation packages to show how quickly the 
procedure progresses. This is actually a control included in the 
Windows Common Controls component and is called the ProgressBar 
control. It's really easy to use: You tell it the beginning and end 
values, and then set that value each time you move through your 
process.


*7. SEARCHING LONG TEXT FIELDS IN SQL SERVER                   
          
One thing I currently do on the ASP Techniques Web site 
(http://www.asptechniques.com) is store all the content in a SQL 
Server database. Because I have some long text articles, I store these 
in ntext fields. The problem is that in SQL Server, ntext fields are 
not searchable using the LIKE keyword. This makes performing keyword 
searches basically impossible. 

However, I've found that I am able to support keyword searches using 
the Full-Text Indexing feature of SQL Server. I simply specify the 
table(s) and field(s) to index, and SQL Server automatically creates a 
full-text index of those fields. The best part is that the SQL query 
still uses the same LIKE keyword. It's basically transparent at the 
SQL level, and since the indexing runs automatically when the system 
isn't busy, it doesn't put extra work on the server.


*8. OWNERSHIP OF CODE                   
          
Here's a non-technical tip for today... A user asked about ownership 
of code that he wrote for a client. The basic answer is: It all 
depends what you negotiated. Typically, if you work full-time for 
someone as an employee, your employer owns anything you create. If 
you're an independent consultant working for a client, it's up to you 
to ensure you both agree to ownership--and get it in writing. 

Typically, I will give ownership to the client but include provisions 
that allow me to use the code for other clients, as long as they don't 
compete directly with the first client. This lets me reuse code I 
develop but still protects the original client's investment. Whatever 
you negotiate, make sure it's on paper. Also, it's a good idea to get 
in touch with an intellectual property lawyer if you're really 
concerned about ownership. They are the only ones qualified to give 
legal advice.


*9. SERVICE PACK 4 NOW AVAILABLE                   
          
Microsoft has recently released Service Pack 4 for Visual Studio. This 
includes a number of fixes, as well as all the fixes included through 
Service Pack 3.  

Visual Studio 6.0 Service Pack 4 
http://msdn.microsoft.com/vstudio/sp/vs6sp4/default.asp


*10. INTRODUCING ADO+                   
          
Microsoft continues to let out sneak peeks of the next version of 
Visual Studio and related technologies. The latest one is ADO+, which 
uses XML for moving data back and forth. You can read more about ADO+ 
on Microsoft's Web site. 

Introducing ADO+ 
http://msdn.microsoft.com/vstudio/nextgen/technology/adoplus.asp
