News 13INETA
Home Up News 15 News 14 News 13 News 12 News 11 News 10 News 9 News 8 News 7 News 6 News 5 News 4 News 3 News 2 News 1

 

Hit Counter Visitors

A SearchVB Member asks, "I am busy developing a Web application using
ASP.NET and I'd like to authenticate the users using the users' WinNT
logins. How do I do that? I read about it here and there and just got
lost somewhere within readings on system.directoryservices, LDAP,
ADSI...can you help?"  CLICK to read our Expert's Answer... http://searchvb.techtarget.com/vsnetATEAnswers/0,293820,sid8_gci819294,00.html 

Member Josh Parks submits this week's featured code. "Allows you to
determine the path of the EXE file in .NET since you cannot use the
app.path feature anymore."  CLICK for the Code Download... http://vbcode.com/Asp/showsn.asp?theID=6752 

DESIGNING A VB.NET APPLICATION 

This week's featured article shows not only how to implement a Web
service server and client, but some of the object oriented issues in
designing a VB.NET application. Click for this and a ton of other
.NET resources. CLICK to read the Featured Topic...
http://searchvb.techtarget.com/featuredTopic/0,290042,sid8_gci819128,00.html 

Windows & .NET Magazine
Order one or both of Windows & .NET Magazine and SQL Server Magazine
and receive 25% off - Satisfaction Guaranteed!
That's right 25% Off
http://www.dotnetjunkies.com/ads/adnav.aspx?AdID=27 

Using Automation (ActiveX/COM) Objects in ASP.NET
By Peter van Ooijen - 4/26/2002
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=337 

Not every technique used in the pre .NET days should be sent to the
recycle bin at this very moment. A technique which suffers greatly
from this misunderstanding is ActiveX, also known as (OLE) automation
or COM. Let Peter convince you why COM is not dead!

Building a Fully Functional DataGrid
By Peter Karl - 4/25/2002
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=333 
Disappointed with the editing capabilities of the ASP.NET DataGrid? In
this article, Peter will show you how to utilize several of the .NET
base classes to construct your own fully featured DataGrid.

Recalculating Column Values in DataGrid
By Bipin Joshi - 4/24/2002
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=334 

This article explains how to dynamically calculate the value of a
DataGrid column based on the values in other columns. Bipin takes you
through how to accomplish this step-by-step.

NET Anatomy: Creating Templated DataGrid Controls Using Visual Studio
NET : Part 1
By Barton Friedland - 4/22/2002
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=332 
This article also shows, step-by-step, how to use Visual Studio .NET
to create templated controls visually, without writing code and then
explores the code that is generated as a result. This provides the
reader with a solid understanding of how Controls can be used in a
very flexible manner to acheive a wide variety of complex data
rendering and capture.

Data Binding Custom Classes
By Xico Loko - 4/19/2002
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=328 
There are a lot of samples that show you how to data bind DataReaders
or DataSets to DataGrids, Repeaters, etc. But what happens if you want
to use your own classes within a collection? This article shows you
how to do it.

How To Fix Web Services Going Though Firewalls
By Ben Hinton - 4/23/2002
http://www.dotnetjunkies.com/howto/default.aspx?id=30 
Ben gives you ideas on what to do when faced with some degree of
firewall and/or proxy server as you are trying to get your Web
Services to work on your corporate network. He gives you a few
suggestions to aid in your development.

Opening Child Windows Using Server Side Controls
By James Barnett - 4/17/2002
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=323 
This article will examine two different ways to open child window from
server controls and will also look at how to pass data back from the
child to the parent and trigger a server side event on the parent form.

Threading Part 4
By Ben Hinton - 4/15/2002
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=321
In Threading Part 4, Ben takes a look at thread synchronization. He
explores what happens when you get into a situation where two or more
threads need to call the same methods at the same time.

Building a Master/Detail DataGrid for Database Inserts
By Bipin Joshi - 4/12/2002
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=319 
In this article, Bipin explains how to build a Web Form where the
requirement is inserting many rows of data against one row of master
data. He builds an example Web Form that you can extend in your
application with two tables - OrderMaster and OrderDetails.

How to Change the IP Address of the Local Machine Using VB .NET
By Ben Hinton - 4/18/2002
http://www.dotnetjunkies.com/howto/default.aspx?id=29 
In this article, Ben shows how to change the IP address of a local
machine using Visual Basic .NET. This functionality is not provided in
the Base Class Library and there is no Win32 API call to do this
either, so this is a manual coding job!

How To Highlight a DataGrid Row
By Steve Eichert - 4/16/2002
http://www.dotnetjunkies.com/howto/default.aspx?id=27 
This How To explains a way to build a searched SQL query and a DataGrid
to display the results of the search and highlight only the record
searched for specifically.

How To Generate PDF Files Dynamically Using ASP.NET
By Hai Wu - 4/11/2002
http://www.dotnetjunkies.com/howto/default.aspx?id=26 
This article removes the mystery and explains how to dynamically
generate a PDF file with ASP.NET. After searching long and hard for
the answer, Hai rolled up his sleeves and found an answer and now he
shares it with you.

Microsoft Jaggled by Cap Gemini Ernst & Young Framework!
Submitted by Donny Mack - 4/17/2002
http://www.dotnetjunkies.com/news/default.aspx?newsid=327 
Microsoft has published a Case Study on Jaggle, an innovative web
framework developed by Cap Gemini Ernst & Youngs Benelux team. Jaggle
is entirely based on Microsoft's newly launched .Net services, and
supports a web-based process of mapping consumer needs to product
characteristics. The Case Study, available at http://msdn.microsoft.com  ,
has been in development for months. The Case Study includes an
in-depth review of Jaggle, how it works, and what benefits it brings
to companies. The source code and documentation supporting the
framework are available online on http://www.jaggle.net . To support their
idea, the team designed a highly realistic sample website about a
real-estate selection application based on Jaggle available on
http://www.jaggle.com .

Quiksoft Offers Free .Net E-Mail Component
Submitted by Laurie Nester - 4/15/2002
http://www.dotnetjunkies.com/news/default.aspx?newsid=322 
FreeSMTP.Net Enables Developers to Send Mail from .Net applications.
Philadelphia, PA - April 1, 2002 - Quiksoft Corporation has announced
the availability of FreeSMTP.Net, a free .Net component that enables
application developers to send Internet e-mail from their .NET
applications. FreeSMTP.Net is available for immediate download.

ASP.NET Validation Controls Samples For Beginners
Submitted by Bipin Joshi - 4/13/2002
http://www.dotnetjunkies.com/news/default.aspx?newsid=320 
ASP.NET frees the programmer from performing common validation tasks
through the use of special web controls called validation controls.
These 10 downloadable code samples will show you how to use all of
the available validation controls.

NEW .NET SOURCE CODE - FlashLight - Flash Server Control v1.0
Learn how to build an ASP.NET Server Control while adding a time-saving component to your programming toolbox. This is the source code for an ASP.NET Server Control that will allow you to programmatically control and set up all of your Flash movie parameters, including all of the standard parameters and any custom parameters that you want. It is built as a single file C# assembly, and can be loaded and customized in Visual Studio .NET.
http://www.angrycoder.com/sc_flashlight10.aspx
 

.NET
- Team Development with Visual Studio .NET and Visual SourceSafe
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/tdlg_rm.asp 

- Choosing Among File I/O Options in Visual Basic .NET
http://msdn.microsoft.com/library/?url=/library/en-us/dv_vstechart/html/vbtchUseFileStreamObject.asp 

Windows
- Windows Script Host 5.6 Boasts Windows XP Integration, Security, New Object Model
http://msdn.microsoft.com/msdnmag/issues/02/05/wsh/wsh.asp 

Office
- Using Microsoft Excel 2002 with SQL Server Analysis Services
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k2/html/odc_xlsql.asp 

Voices
- At Your Service: XML Web Service Caching Strategies
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dn_voices_webservice/html/service04172002.asp 

HOW TO: Enable Replication Agents for Logging to Output Files in SQL Server (Q312292)
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312292&SD=MSKB& 

HOW TO: Set Up and Troubleshoot a Linked Server to Oracle in SQL Server (Q280106)
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q280106&SD=MSKB& 

INF: How To Transfer Logins and Passwords Between SQL Servers (Q246133)
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q246133&SD=MSKB& 

MICROSOFT GULF COAST MSDN SEMINARS
Chart your course for warp speed.
At MSDN training events, learn how to move your development cycle to warp speed. Discover for yourself just how far .NET can take you. Join us for our April and May topics and you'll receive a chance to win cool Microsoft software, hardware, and MS Press books. For a detailed description of the topics and to register, visit
http://www.developercare.com 

Use XSLT in .NET
The .NET platform makes it easy to use XSLT to transform XML into a variety of structures. Here's how to use managed classes in the .NET base class library to transform XML into HTML. [Read More]

5 Page Template Tips
Jonathan Goodyear answers five common questions about ASP.NET page templates, and provides a download containing an upgraded version of his ASP.NET PageTemplate class. [Read More]

When Web Services Don't Make Sense
Everyone tells you how great Web services are, but don't assume they'll solve every problem you'll ever face. Learn some scenarios where it doesn't make sense to use Web services. [Read More]

Generate Custom Crosstab Reports
Creating crosstab reports with T-SQL is a hot topic in the SQL Server community—and you'll probably need to design high-performance XML Web services that generate ad hoc crosstab reports. Roger Jennings shows you a new approach. [Read More]

Test Web Services Without Writing a Client
Use Microsoft's newly released .NET WebService Studio to test .NET interoperability with a variety of publicly accessible or local Web services. Roger Jennings shows you how it works. [Read More]

Provide Rich Functionality With Server Controls
Server controls offer a stronger design-time experience and distribution model than user controls. See how to encapsulate rich functionality in your ASP.NET apps using server controls. [Read More]

Build a Forum Using ADO.NET
Build a customized Web-based forum using ADO.NET and ASP.NET. A custom solution gives you greater flexibility to tailor the forum's look and functionality to match your Web site. [Read More]

Global Error Handlers for WinForms Applications
by Francesco Balena (fbalena@vb2themax.com)
Excerpt from Chapter 16 of "Programming Microsoft Visual Basic .NET"
(Microsoft Press)

The ThreadException of the Application event lets you leverage a very powerful feature of the Windows Forms package, so it deserves a section of its own. To understand why this feature is so important, let's review what happens when an unhandled error occurs inside an event routine. In normal circumstances, the exception would be passed to the caller code, but an event procedure has no caller, so errors of this kind terminate the application. Visual Basic 6 developers are well aware of this issue, and in fact are inclined to liberally furnish all event procedures with On Error statements. This technique is ugly and tends to decrease performance, but it's the only one that ensures a sufficient level of robustness.

The Application.ThreadException event fires whenever an unhandled exception is thrown on the current thread, so you can easily write a global error handler that protects all your forms from any unhandled errors. Your global handler can ignore the error, log it to a file, display a message box that asks the end user whether he or she wants to abort the application, send an e-mail to the tech support group, and any other action you deem desirable.

To implement this feature correctly, you must use a Sub Main procedure as the startup object of your application and you must mark it with the STAThread attribute to set the threading model of the application to Single Thread Apartment (STA) mode. After you set up the ThreadException event, you can start the main form by using an Application.Run method, as shown in the following code:
Module MainModule
   <STAThread()> _
   Sub Main()
      ' Install the event handler.
      AddHandler Application.ThreadException, _
          AddressOf Application_ThreadException
      ' Run the startup form.
      Application.Run(New ApplicationForm())
   End Sub

   ' This is the global error handler.
   Sub Application_ThreadException(ByVal sender As Object, _
      ByVal e As System.Threading.ThreadExceptionEventArgs)

      Try
          ' Prepare an informative message.
          Dim msg As String = _
              String.Format _
	("An error has occurred:{0}{0}{1}{0}{0}{2}", _
              ControlChars.Cr, e.Exception.Message, _
			  e.Exception.StackTrace)
          ' Display it, asking whether the application _
	           should terminate.
          Dim result As DialogResult = _
              MessageBox.Show(msg, "Application Error", _
              MessageBoxButtons.AbortRetryIgnore, _
		 MessageBoxIcon.Error)
          ' End the application if the end user said so.
          If result = DialogResult.Abort Then
              Application.Exit()
          End If
Catch
          ' If the message box couldn't be displayed _
		       (presumably because
          ' the Exception object wasn't available, _
		       try with a simpler
          ' one, and then close the application anyway.
          '
          Try
              MessageBox.Show _
	("The application will be terminated", _
                      "Fatal Error", _
		MessageBoxButtons.OK, MessageBoxIcon.Error)
          Finally
              Application.Exit()
          End Try
      End Try
  End Sub
End Module
The global error handler serves all the unhandled exceptions of your application, including the most critical ones. For this reason, the code inside the handler should account for exceptional conditions--for example, the case when the e.Exception object isn't available or when it isn't possible to display a message box. (In the latter case, you might want to log the error to the system log or to a bug report file.)

An important note: this feature clashes with Visual Studio debugger, and global error handlers don't work well when the application runs inside Visual Studio. To see it in action, you should run the program using the Start Without Debugging command in the Debug menu (which corresponds to the Ctrl-F5 key), or run it from Windows Explorer or the command prompt.

Enhanced Exception Report Routine
Last issue's VB.NET Watcher column contained a routine that dumps the stack contents when an exception is throw; you just pass an Exception object to it and the routine prints name and other information about the call stack in the moment when the exception was thrown. Eddie Butt of London Life Insurance improved the routine to display the name of parameters passed to each routine (but not their value, which can't be obtained through reflection). Here's the improved version:
' The following routine requires the following Imports statements
'   Imports System
'   Imports System.Reflection

' A reusable routine that displays error information
Sub DisplayExceptionInfo(ByVal e As Exception)
   ' Display the error message.
   Console.WriteLine(e.Message)

   Dim st As New StackTrace(e, True)
   Dim i As Integer

   For i = 0 To st.FrameCount - 1
       ' Get the i-th stack frame.
       Dim sf  As StackFrame = st.GetFrame(i)
       ' Get the corresponding method for that stack frame.
       Dim mi As MemberInfo = sf.GetMethod
       ' Get the namespace where that method is defined.
       Dim res As String = mi.DeclaringType.Namespace & "."
       ' Append the type name.
       res &= mi.DeclaringType.Name & "."
       ' Append the name of the method.
       res &= mi.Name
Dim objParameters() As ParameterInfo = _
           sf.GetMethod.GetParameters()
       Dim objParameter As ParameterInfo
       Dim strParameterString As String = ""
       strParameterString &= "("
       For Each objParameter In objParameters
           'Only add commas if there are more than one parameter
           ' (default length of 0 plus the opening parenthesis = 1).
           If strParameterString.Length <> 1 Then
               strParameterString &= ", "
           End If
           strParameterString &= objParameter.Name & " As " & _
               objParameter.ParameterType.Name
       Next
       strParameterString &= ")"
       res &= strParameterString

       ' Append information about the position in source file
       ' (but only if Debug information is available).
       If sf.GetFileName <> "" Then
           res &= " (" & sf.GetFileName & ", Line " & _
               sf.GetFileLineNumber & ", Col " & _
                   sf.GetFileColumnNumber
       End If
       ' Append information about offset in MSIL code, if available.
       If sf.GetILOffset <> StackFrame.OFFSET_UNKNOWN Then
           res &= ", IL offset " & sf.GetILOffset.ToString
       End If
       ' Append information about offset in native code.
       res &= ", native offset " & sf.GetNativeOffset & ")"

       Console.WriteLine(res)
   Next
End Sub

Gaining Control of the .NET ListBox
by A. Russell Jones
Although .NET's Windows Forms ListBox control has extended capabilities, it can be problematic when attempting some of the simplest things. This article demonstrates how the use of delegates can help you achieve near-total control. (from the .NET Zone)

Build a Custom Grid Collection
by Stan Schultes
Extend a VB Collection object by building a collection class around it to manage the display configuration of columns in a data grid. Then, load and store column display settings from an application INI using code you can add to your own apps.

Knowledge Base Articles to Get Started with VB.NET
This week we have gathered the most useful Microsoft Knowledge Base Articles that explain the fundamentals of Visual Basic .NET, Visual Studio .NET, and the .NET Framework. First comes a series of roadmap articles that introduce a topic and illustrate where to go for further operations:

INFO: Roadmap for Migrating Visual Basic 6.0 to Visual Basic .NET (Q317071)
INFO: Roadmap for Using ADO in .NET (Q308044)
INFO: Roadmap for .NET Data Providers (Q313480)
INFO: Roadmap for ADO.NET DataAdapter Objects (Q313483)
INFO: Roadmap for ADO.NET DataSet, DataView, and DataViewManager Objects (Q313485)
INFO: ASP.NET Roadmap (Q305140)
INFO: Roadmap for Threading in Visual Basic .NET (Q316422)
INFO: Roadmap for Debugging in .NET Framework and Visual Studio .NET (Q308626)
INFO: Roadmap for Windows Forms Data Binding (Q313482)
INFO: Roadmap for XML Integration with ADO.NET (Q313649)
INFO: Roadmap for Programming XML with the DOM-Model Parser in the .NET Framework (Q313824)
INFO: Roadmap for Programming XML with the Pull-Model Parser in the .NET Framework (Q313816)
INFO: Roadmap for XML Schemas in the .NET Framework (Q313826)
INFO: Roadmap for Executing XPath Queries in .NET Applications (Q313828)
INFO: Roadmap for .NET Enterprise Services (Q308672)

The next list is a series of HOW TO articles that explain how to perform common operations with Visual Basic .NET:
HOW TO: Create Threads in Visual Basic .NET (Q315677)
HOW TO: Create Visual Basic .NET Classes for Equivalent Visual Basic 6 Component Instancing Properties (Q311320)
HOW TO: Catch Exceptions in Visual Basic .NET (Q301283)
HOW TO: Use Structured Exception Handling in Visual Basic .NET (Q315965)
HOW TO: Use Inheritance in Visual Basic .NET (Q307222)
HOW TO: Trace and Debug in Visual Basic .NET (Q313417)
HOW TO: Read from and Write to a Text File by Using Visual Basic .NET (Q315828)
HOW TO: Use ActiveX Components in Visual Studio .NET with Visual Basic .NET (Q315847)
HOW TO: Use the Visual Basic Upgrade Wizard (Q317885)

Dual Use of a Lookup Query
Usually in your application you use two different types of lookup queries; the first one is for retrieving a page of records (or all records) to populate a pick list, the other one is to retrieve a single record, i.e. for decoding a code description while a user is typing it in a textbox. So, if your queries are dynamically configured and are stored in a DB, you must duplicate the list of query statements. So you'll use it in the first situation, a query such as:
SELECT * FROM PUBLISHERS
In the other situation you'll use a query like:
SELECT * FROM PUBLISHERS WHERE COUNTRY = ?
But you can use just one query structured in dual mode:
SELECT * FROM PUBLISHERS WHERE (COUNTRY = ? OR 1 = ?)
When you want to populate a pick list you'll pass to the second parameter simply a 1 and all records will be retrieved. When you want to decode a single value, you must pass the code to the first parameter and a 0 to the second one. So, if all your queries use always one parameter to decode value, you can write a standard (dual) lookup routine like this:
Dim lConn As ADODB.Connection
Dim lCmd As ADODB.Command
Dim lRs As ADODB.Recordset
Dim lParAllRecords as Long
Dim lParSingleRecord as Long

Set lConn = New ADODB.Connection
lConn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User

ID=sa;Initial Catalog=PUBS;Data Source=(local)"
lConn.CursorLocation = adUseClient
Set lCmd = New ADODB.Command
Set lCmd.ActiveConnection = lConn
lCmd.CommandText = txtStatement.Text

'if you want all records:
lParAllRecords = 1
lParSingleRecord = 0 'not important in the first use

'if you want a single record:
lParAllRecords = 0
lParSingleRecord = "Germany" 'the correct value to retrieve one record

lCmd.Parameters(0).Value = lParSingleRecord
lCmd.Parameters(1).Value = lParAllRecords
Set lRs = lCmd.Execute

Extract RGB Components from a Long Value
By Roger Johansson

You can extract RGB values out of a 32-bit color value by using the integer division and the MOD operators, but there is a much more effective way, based on the LSet. You can convert from a Long to RGB bytes and vice versa with the following code:
Private Type RGBWrapper
   Red As Byte
   Green As Byte
   Blue As Byte
   Alpha As Byte
End Type

Private Type LONGWrapper
   Value As Long
End Type

Private Sub Form_Load()
   Dim Color As LONGWrapper
   Dim Colors As RGBWrapper
   Color.Value = RGB(255, 123, 55)
   LSet Colors = Color 'do the actual conversion
   MsgBox Colors.Red
   MsgBox Colors.Green
   MsgBox Colors.Blue
End Sub

 

 
Send mail to vblg@xocomp.net with questions or comments about this web site.
Copyright © 1998-2003 XOCOMP, llc
Last modified: 05/07/2002