asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search








Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Accessing Caller ID from the Web - Part 1
By Paul Apostolos
Rating: 4.1 out of 5
Rate this article


  • email this article to a colleague
  • suggest an article

    Introduction

    This series of articles will demonstrate how to build an application that saves incoming caller id information to a SQL Server database; create a Web service that exposes methods for reading and deleting the information; build a proxy class for consuming the Web service; and develop an ASP.NET page that can be used to access the service.

    This article assume you have the following:

    • A fairly cheap computer running any flavor of a Windows Server.
    • A caller id enabled modem connected to the server.
    • Caller id service from your local phone company.
    • An always-on Internet connection capable of serving Web content.
    • A DNS client if you do not have a static IP address.

    I'll start by writing the Visual Basic (VB) program that runs on the server and updates a database with incoming callers.

    The code assumes that you have MSComm32.OCX installed and registered on the machine that will be serving the caller id information.

    The Code

    To begin, open Visual Basic 6 and choose Standard EXE as the type of project.

    Then add a label to the form and change its properties as shown in the following screenshot.

    The most important part of this program is the use of the MSComm component. We'll need to add the component to the project. To do this, click the Project menu and choose components.

    Then check the Microsoft Comm Control 6.0 and click okay.

    Now there will be a small yellow telephone icon in the toolbox.

    Double click the telephone icon to add the component to the form. The icon will not be visible at runtime; it shows up on the form to allow you to set properties of the component using the IDE.

    Double click on the form to bring up the code for the form. By default the Form_load Sub's skeleton will be written.

    Copy and paste the following code into the code area. (Overwrite the contents)

    
    Public Call_Name As String
    Public Call_Number As String
    Private Sub Form_Load()
        With MSComm1
            .Settings = "9600, N, 8, 1"	'// Baud, Parity, Data Bits, Stop Bits
            .CommPort = 2			'// Change to the port of your modem              
    		
            If .PortOpen = False Then		'// If the port is not already open
    			.PortOpen = True	'// open it
    	End if
            
    	.RThreshold = 0
            .InputLen = 0
           
    	.Output = "AT#CID=1" & Chr(13)	'// Send the modem the 
    	   				  	'// appropriate AT command
    					  	'// to enable the modem to 
    					  	'// sit and wait for
    					  	'// incoming calls and capture
    					  	'// the caller id information
    					  	'// Check the modem's documentation
    					  	'// for the correct string
        End With
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    
        MSComm1.PortOpen = False	'// Close the port when the 
    					'// program is closed
        
    End Sub
    
    Private Sub MSComm1_OnComm()
    Dim Buffer As String 			 '// Will hold the string
    					 '// from the modem
    	
    	'// I was having problems dealing with 
    	'// the returns and line feeds so I deleted
    	'// them from the Buffer
            
    	Buffer = Replace(MSComm1.Input, Chr(13), "")
    	Buffer = Replace(Buffer, Chr(10), "")
        
        GetCallerInfo (Buffer)
        
    End Sub
    
    Private Sub GetCallerInfo(Caller_Id_string As String)
            
                 
            If InStr(Caller_Id_string, "NAME") > 0 Then
            
               Call_Name = Mid(Caller_Id_string, (InStr(Caller_Id_string, "NAME = ") + 7), _
                    ((InStr(Caller_Id_string, "NMBR = ") - 7) - InStr(Caller_Id_string, "NAME = ")))
                   
            End If
               
            If InStr(Caller_Id_string, "NMBR") > 0 Then
            
                Call_Number = Mid(Caller_Id_string, (InStr(Caller_Id_string, "NMBR = ") + 7))
                  
            End If
               
                   
            If Len(Call_Name) > 1 Or Len(Call_Number) > 1 Then
    
                Call Database_Update()
        
            End If
    
    
    End Sub
    
    Private Function Database_Update()
    
            Dim Command_Text As String
    
            Command_Text = "Insert Into tbl_Caller_Id (Call_Name, Call_Number)" & _
                "Values ('" & Call_Name & "', '" & Call_Number & "')"
    
            Dim myConnection As New ADODB.Connection
            
            myConnection.Open "Driver={SQL Server};" & _
                              "Server=localhost;" & _
                              "Database=mydb;" & _
                              "Uid=;" & _
                              "Pwd=;"
                              
            myConnection.Execute (Command_Text)
    
            myConnection.Close
    
            Call_Name = ""     '// Set the values back to nothing
            Call_Number = ""
    
    End Function
    
    

    All that's left is to go to the file menu and choose the make .exe option.

    Conclusion

    A .zip file containing the form, code and project for the above application can be found here.

    Run this program on the Web server that is connected to the Internet and a phone line using a caller id capable modem.

    The program receives the caller id information from the modem, parses the information and dumps the output to a SQL server database. The code can be easily modified to dump to an Access database. If you have trouble with the modification e-mail me.

    In part two I'll build a Web service that exposes methods for reading and deleting the caller id information from the database.

    About the Author

    Paul Apostolos is Director of Internet Development for the National Roofing Contractors Association (www.nrca.net). Paul has more than 5 years experience programming and developing Web sites based on Microsoft technologies. He can be reached at paul@allpaul.com.

  • Rate This Article
    Not HelpfulMost Helpful
    1 2 3 4 5
    Other Articles
    Apr 27, 2004 - Develop and Customize Web Parts with Custom Tool Parts
    Tool Parts provide an interface for Web Part properties well beyond the capabilities of the default property pane. In this article Gayan Peiris shows how to customize Web Parts with custom Tool Parts.
    [Read This Article]  [Top]
    Apr 7, 2004 - Reusable Components in ASP.NET 2.0, Object Binding and Precompilation
    This article demonstrates how to create a reusable component in ASP.NET 2.0 and then consume it from an ASP.NET page. Also learn how the ObjectDataSource control can be used to directly bind the output of an object to the controls in an ASP.NET page and how precompilation can be used to increase the performance of the Web application and catch compilation errors.
    [Read This Article]  [Top]
    Mar 31, 2004 - Build a Managed BHO and Plug into the Browser
    Browser Helper Objects (BHOs) are COM components that communicate with Internet Explorer to enrich the browsing experience. Michele Leroux Bustamante returns to the world of COM to show you how to build a managed BHO with the help of the .NET Framework's COM interoperability features.
    [Read This Article]  [Top]
    Feb 18, 2004 - Customizing SharePoint Web Parts with Custom Properties
    In addition to creating custom Web Parts for SharePoint Portal Server, developers can actually create their own custom properties to further enhance Web Part appearance and behavior. Gayan Peiris explains the process and provides all the necessary code.
    [Read This Article]  [Top]
    Sep 26, 2003 - Accessing Shared Resources Using ASP.NET
    Accessing shared resources is a challenge for many ASP.NET developers. Tony Arslan explains how a simple serviced component can solve this infamous problem.
    [Read This Article]  [Top]
    Oct 2, 2002 - Function Pointers and COM
    Using callbacks and function pointers in VB can be risky and complicated. Ben Garcia explains his work-around for the function pointer issue he encountered while creating the VB version of his SNMP component.
    [Read This Article]  [Top]
    Sep 4, 2002 - Creating an SNMP Component - Part 2
    In part two of this intriguing article series, Ben Garcia shows how to build an updated and improved SNMP component in VC++ AND VB, and he briefly explains why limitations in VB make VC++ a better language for developing this type of application.
    [Read This Article]  [Top]
    Jul 23, 2002 - Creating an SNMP Component
    Ben Garcia sheds some light on the Simple Network Management Protocol (SNMP). First he provides a history of SNMP, then he dives right into its architecture. Finally, he shows how to build a COM component that communicates with SNMP-enabled devices.
    [Read This Article]  [Top]
    Nov 20, 2001 - Creating a Server Component with VB - Redesigned - Part 2
    Doug Dean explains different methods of retrieving and manipulating data from a database in a VB DLL so that it is ready to be rendered in a browser.
    [Read This Article]  [Top]
    Aug 28, 2001 - Create Your Own Visual Basic Add-Ins
    In this article, S.S. Ahmed shows you how to create VB add-ins. Programmers always feel that they are short of several features while working with development tools. Since Microsoft made Visual Basic an extensible product, VB developers can create their own features in VB.
    [Read This Article]  [Top]
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry



    JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
    Avaya Article: How to Feed Data into the Avaya Event Processor
    Microsoft Article: Install What You Need with Win Server ‘08
    HP eBook: Putting the Green into IT
    Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
    Avaya Article: Setting Up a SIP A/S Development Environment
    IBM Article: How Cool Is Your Data Center?
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    Intel Video: Are Multi-core Processors Here to Stay?
    On-Demand Webcast: Five Virtualization Trends to Watch
    HP Video: Page Cost Calculator
    Intel Video: APIs for Parallel Programming
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Sun Download: Solaris 8 Migration Assistant
    Sybase Download: SQL Anywhere Developer Edition
    Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
    Red Gate Download: SQL Compare Pro 6
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
    eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
    IBM Article: Collaborating in the High-Performance Workplace
    HP Demo: StorageWorks EVA4400
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES