Locations of visitors to this page


Onteora Software - June 2007

Onteora Software

Ken Tucker's Blog

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

VB 2008 Extension Methods

VB 2008 Extension Methods


Visual Basic 2008 adds a new features called extension methods.   These allow you to add a method, or function to a type.  For this example we will add an IsGuid function to strings.  All extension methods must be placed in a module.  The function or method must be marked as an extension and the first argument is the type the method extends.



Imports System.Runtime.CompilerServices
Imports System.Text.RegularExpressions

Module Module1

    Sub Main()
        Dim g As String = "82ee4145-632c-42a1-83b9-57ec163eaa17"
        Dim g1 As String = "82ee4145-632c-42a1-83b9-57ec163ea17"

        Console.WriteLine(g & IIf(g.IsGuid, " is ", " is not ") & "a valid guid")
        Console.WriteLine(g1 & IIf(g1.IsGuid, " is ", " is not ") & "a valid guid")
    End Sub

End Module

Public Module MyExtensions

    <Extension()> _
    Public Function IsGuid(ByVal s As String) As Boolean
        Dim regGuid As New Regex("^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$", RegexOptions.Compiled)
        Return regGuid.IsMatch(s)
    End Function
End Module

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: VS 2008
Posted by Ken Tucker on Friday, June 29, 2007 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Sql Endpoint and DataGridView

Sql Endpoint and DataGridView

SQL Server 2005 allows you to create webservices for accessing the data in a database.  These webservices are call SQL End Points.  Lets start by creating a stored procedure to get the contact name and there titles for all the customers in the northwind database.  

Create PROCEDURE [dbo].[GetContacts]
AS
BEGIN
    SET NOCOUNT ON;

    SELECT [ContactName],[ContactTitle] FROM Customers ORDER BY [ContactName];
END

Now we can create the end point.  Note for this example I am using port 88 for the end point to prevent errors if you have IIS installed.

CREATE ENDPOINT NW_Contacts
    STATE = Started
AS HTTP
    (
        PATH = '/Contacts',
        AUTHENTICATION = (INTEGRATED),
        PORTS = (CLEAR),
CLEAR_PORT = 88,
        SITE = '*'
    )
FOR SOAP
    (
        WEBMETHOD 'GetContacts'
            (NAME = 'Northwind.dbo.GetContacts'),
        WSDL = DEFAULT,
        DATABASE = 'Northwind',
        NAMESPACE = DEFAULT
    )


Now we need to create a windows forms application.  I called the app EndPointTest.  On the form add a datagridview and set its dock property to fill.
Then add a web reference to the app.  For the url use http://localhost:88/contacts?WSDL.  For the name I used ContactEndPoint.
Here is some sample code for filling the datagridview with data from the end point

Imports System.Net

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ws As New ContactEndPoint.NW_Contacts

        ws.Credentials = CredentialCache.DefaultCredentials

        Dim ds As DataSet = TryCast(ws.GetContacts(0), DataSet)
        DataGridView1.DataSource = ds.Tables(0)

    End Sub
End Class

Currently rated 2.7 by 3 people

  • Currently 2.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: DataGridView | Sql
Posted by Ken Tucker on Wednesday, June 27, 2007 1:12 AM
Permalink | Comments (0) | Post RSSRSS comment feed

July Space Coast .Net Meeting

July Space Coast .Net Meeting



When: July 18 @ 6:30 PM

Where:  Space Coast Credit Union Corp headquarters

Connecting Applications with WCF

Most applications of any scale need to make remote calls. Whether you need to call across processes from your smart client to a web service, from your web server to your application server, or from one client to another in a peer to peer fashion, WCF supports any kind of remote messaging or communications scenario. It doesn’t just stop at remote calls either, but also supports multiple forms of security, distributed transactions, queuing, concurrency, callbacks and many other things that are needed in full blown enterprise scale Service Oriented Architecture applications. This talk will show you the basics of using WCF to connect applications. You will learn what WCF is all about, how it relates to other remoting technologies, how to create a service, how to connect a client, and will expose you to the other many facets of WCF.

Bio:

Brian Noyes is a software architect with IDesign Inc (www.idesign.net), the Microsoft Regional Director for the Mid-Atlantic Region, a Solution Architect MVP, writer, speaker, and trainer. He is a frequent speaker at industry conferences worldwide including Microsoft TechEd US, Europe, and Malaysia, DevConnections, DevTeach, SDC Netherlands, .NET Days Denmark, and others. His last book, Data Binding in Windows Forms 2.0, came out in January 2006, and his latest book Smart Client Deployment with ClickOnce hit the shelves in January 2007. Brian also recently completed a LiveLessons training DVD named Developing Applications with Windows Workflow Foundation that will be out in the April 2007 timeframe. Brian got started programming as a hobby while flying F-14 Tomcat’s in the Navy, graduating from both TopGun and U.S. Naval Test Pilot School. He later turned his love of programming into his current career.

 

 

Please register to attend this event

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Events | User Group
Posted by Ken Tucker on Tuesday, June 12, 2007 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed