Blog - Title

Visual Studio 2013 Current Status

  • The Ultimate Visual Studio Tips and Tricks Blog

    On The Air!

    • 1 Comments

    I'm finally starting to catch up with my blogging and wanted to show off some pics from a radio show I did on October 21st.  A buddy of mine Winston does the Innovation@Work show on KSKY every Sunday.

     

     img_6371

     

     

    We had the CEO of StarPower, David Pidgeon, on and he was a great guest. 

     

    img_6349

     

    Awesome guy btw and very friendly.

     

    I was the co-host as we talked about home theatre systems and where the technology is today versus where it is going.  Good times!

     

    img_6417

     

    It was my radio premier and I loved every minute of it!  David brought his kids along and we watched football during the breaks.  I'm looking forward to the next show (sometime around the second week in November).

     

  • The Ultimate Visual Studio Tips and Tricks Blog

    On The Road Again...

    • 1 Comments

    Paying a Visit

    So I'm headed to Topeka, Kansas.  Why?  To hook up with the local .NET User Group there and show some them some Microsoft love :)  The president of the group approached me a looooooooong time ago and we just now finally are getting to the point where I can head out there.  I'm pretty excited actually.  Looking forward to partying with the good folks of Topeka and doing my WPF session. 

     

    If you have been to Topeka and know a cool place to visit let me know.  For those not cool enough to visit the city I thought I would throw in some interesting facts.

     

    Did You Know?

    Topeka is the capital of Kansas?

    The community was laid out in 1854 near the point where the Santa Fe Trail and Oregon Trail separated?

     

     

    Technorati Tags: , , , ,
  • The Ultimate Visual Studio Tips and Tricks Blog

    Simple Composition with Windows Presentation Foundation (WPF)

    • 1 Comments

    I did this demo some time ago but never shared it and thought it would be a good idea to get it out to everyone.  When I created it a few months back I was giving a session on WPF and I wanted to have a very simple example of composition.  I couldn't really find one at the time and thus this demo was born. 

     

    What you need to get started:

    Visual Studio 2008 Beta 2

     

    1. Bust out a new WPF Project in C#

      image
    2. Now slap a couple of buttons and a textbox on the form.  Make them look like the figure below.  Don't worry about the names of the controls, we will change them in a second.

      image
    3. Now make modifications to the XAML code as seen below.  The main things to note here are the Name attributes and the removal of the Margin attribute from the TextBox control.  Don't sweat the other attributes as they may be different for you.  Unless you're massively anal retentive then by all means make your code EXACTLY like mine.  Good luck figuring out where I put all the spaces muhahahaha.

      image
    4. Now we want to put the TextBox inside (yes, I said INSIDE) the button called btnMain (the big one).  Cut the element and replace the word "Button" with our element like so:

      image

      Your form should now look like this:

      image

      You might want to widen the TextBox a bit:

      image
    5. Just for fun, run your code and see what you have so far.  It's not pretty but it is very cool to have a TextBox inside the button.  But wait there's more!

    6. Stop debugging and let's put some code into our project.  To do this we want to wire up some events.  We will do one the traditional way just to show it still works and then one the "new" way.  First, double click on the edit button on your form to get to our code.  Now type in the following:

      image
    7. Looks funky doesn't it?  Don't worry you will understand what is does in a minute.  Now go to your XAML and let's make a new event for the TextBox.  Specifically, we are looking to have a KeyDown Event in place.  Add an KeyDown attribute to the TextBox (you should get IntelliSense to help you out) and then choose "<New Event Handler>" from the IntelliSense choice just like so:

      image
    8. Now go over to your code behind file and you should see an event all ready for some code. 

      image
    9. When the user presses enter we want to have some thing happen so put in an conditional block to deal with someone pressing enter

      image
    10. Here is the fun part.  We want to set the button's Content to the text that was typed into out textbox.  This will "set" what the button displays.  The finished event should look like this:

      image
    11. Now go back and look at step 6.  Does it make sense?  When we want to "edit" the text we set the button's content to an actual textbox but when we are done editing then we want to "set" the button's content to just some plain old text.  Run you project and type some text into the textbox.

       image
    12. Now press Enter and see what happens:

      image
    13. Sweet!  So the button began with a textbox as its content then when we pressed enter its content was changed to the text that we typed in.  But what happens when we click the edit button?  Do it and find out :)

      image 

      Type in some new text and have fun with it.
    14. That's it!! Enjoy!


  • The Ultimate Visual Studio Tips and Tricks Blog

    Zain on the radio?

    • 2 Comments

    Looks like I might be doing a regular gig on the AM dial soon.  More details as I get them...

  • The Ultimate Visual Studio Tips and Tricks Blog

    Larry Clarkin and Halo 3

    • 2 Comments

    If you look in the lower left of the navigation you will see I have added a new bud, Larry Clarkin.  Not only is he a cool guy and good friend but he takes a sadistic pleasure in beating the crud out of me in Halo 3 matches.  Nothing says lovin' like getting a beat down in midair. :P  Do me a favor and give him my love if you spank him in a match.  His gamertag is Bottom9th.  Game on!!!

  • The Ultimate Visual Studio Tips and Tricks Blog

    Joins II: Use the Data Source Luke

    • 4 Comments

    At my Houston MSDN Event (http://www.msdnevents.com) I had a student ask me if it was possible to do a Join between different data sources using LINQ.  Specifically, he asked about joining XML data with SQL data.  So I thought "What the hell, let's give it a shot."  It turns out you CAN do joins between different data sources with no problems that I can see.  Here is my example of how to join SQL and XML data using LINQ:

     

    1. First, make sure you have a connection to a database.  In this case, I decided to use the Northwind database.

      image
    2. Now create a new C# web project and call it "I_Love_XML_and_SQL".

      image
    3. Now add a new Linq to SQL Classes item to your project.  Just leave the name of it "DataClasses1.dbml".

      image
    4. Now Click and Drag the Customers table from your connection onto the design surface.

      image
    5. Your should now have something like this:

      image
    6. Okay, so this next part is a little tricky.  We need some XML to play with.  There are a variety of ways we could get the XML.  I am going to provide you the XML but I thought you might like to know how I got it for future reference.  I just ran the following query against the Customers table in SQL Server 2005:

      image
    7. Add a new XML file to your project and replace the existing XML with this:

      <?xml version="1.0" encoding="utf-8" ?>
      <root>
        <customers CustomerID="ALFKI" CompanyName="Alfreds Futterkiste" ContactName="Maria Anders" ContactTitle="Sales Representative" Address="Obere Str. 57" City="Berlin" PostalCode="12209" Country="Germany" Phone="030-0074321" Fax="030-0076545" />
        <customers CustomerID="ANATR" CompanyName="Ana Trujillo Emparedados y helados" ContactName="Ana Trujillo" ContactTitle="Owner" Address="Avda. de la Constitución 2222" City="México D.F." PostalCode="05021" Country="Mexico" Phone="(5) 555-4729" Fax="(5) 555-3745" />
        <customers CustomerID="ANTON" CompanyName="Antonio Moreno Taquería" ContactName="Antonio Moreno" ContactTitle="Owner" Address="Mataderos  2312" City="México D.F." PostalCode="05023" Country="Mexico" Phone="(5) 555-3932" />
        <customers CustomerID="AROUT" CompanyName="Around the Horn" ContactName="Thomas Hardy" ContactTitle="Sales Representative" Address="120 Hanover Sq." City="London" PostalCode="WA1 1DP" Country="UK" Phone="(171) 555-7788" Fax="(171) 555-6750" />
        <customers CustomerID="BERGS" CompanyName="Berglunds snabbköp" ContactName="Christina Berglund" ContactTitle="Order Administrator" Address="Berguvsvägen  8" City="Luleå" PostalCode="S-958 22" Country="Sweden" Phone="0921-12 34 65" Fax="0921-12 34 67" />
        <customers CustomerID="BLAUS" CompanyName="Blauer See Delikatessen" ContactName="Hanna Moos" ContactTitle="Sales Representative" Address="Forsterstr. 57" City="Mannheim" PostalCode="68306" Country="Germany" Phone="0621-08460" Fax="0621-08924" />
        <customers CustomerID="BLONP" CompanyName="Blondesddsl père et fils" ContactName="Frédérique Citeaux" ContactTitle="Marketing Manager" Address="24, place Kléber" City="Strasbourg" PostalCode="67000" Country="France" Phone="88.60.15.31" Fax="88.60.15.32" />
        <customers CustomerID="BOLID" CompanyName="Bólido Comidas preparadas" ContactName="Martín Sommer" ContactTitle="Owner" Address="C/ Araquil, 67" City="Madrid" PostalCode="28023" Country="Spain" Phone="(91) 555 22 82" Fax="(91) 555 91 99" />
        <customers CustomerID="BONAP" CompanyName="Bon app'" ContactName="Laurence Lebihan" ContactTitle="Owner" Address="12, rue des Bouchers" City="Marseille" PostalCode="13008" Country="France" Phone="91.24.45.40" Fax="91.24.45.41" />
        <customers CustomerID="BOTTM" CompanyName="Bottom-Dollar Markets" ContactName="Elizabeth Lincoln" ContactTitle="Accounting Manager" Address="23 Tsawassen Blvd." City="Tsawassen" Region="BC" PostalCode="T2F 8M4" Country="Canada" Phone="(604) 555-4729" Fax="(604) 555-3745" />
        <customers CustomerID="BSBEV" CompanyName="B's Beverages" ContactName="Victoria Ashworth" ContactTitle="Sales Representative" Address="Fauntleroy Circus" City="London" PostalCode="EC2 5NT" Country="UK" Phone="(171) 555-1212" />
        <customers CustomerID="CACTU" CompanyName="Cactus Comidas para llevar" ContactName="Patricio Simpson" ContactTitle="Sales Agent" Address="Cerrito 333" City="Buenos Aires" PostalCode="1010" Country="Argentina" Phone="(1) 135-5555" Fax="(1) 135-4892" />
        <customers CustomerID="CENTC" CompanyName="Centro comercial Moctezuma" ContactName="Francisco Chang" ContactTitle="Marketing Manager" Address="Sierras de Granada 9993" City="México D.F." PostalCode="05022" Country="Mexico" Phone="(5) 555-3392" Fax="(5) 555-7293" />
        <customers CustomerID="CHOPS" CompanyName="Chop-suey Chinese" ContactName="Yang Wang" ContactTitle="Owner" Address="Hauptstr. 29" City="Bern" PostalCode="3012" Country="Switzerland" Phone="0452-076545" />
        <customers CustomerID="COMMI" CompanyName="Comércio Mineiro" ContactName="Pedro Afonso" ContactTitle="Sales Associate" Address="Av. dos Lusíadas, 23" City="Sao Paulo" Region="SP" PostalCode="05432-043" Country="Brazil" Phone="(11) 555-7647" />
        <customers CustomerID="CONSH" CompanyName="Consolidated Holdings" ContactName="Elizabeth Brown" ContactTitle="Sales Representative" Address="Berkeley Gardens 12  Brewery" City="London" PostalCode="WX1 6LT" Country="UK" Phone="(171) 555-2282" Fax="(171) 555-9199" />
        <customers CustomerID="DRACD" CompanyName="Drachenblut Delikatessen" ContactName="Sven Ottlieb" ContactTitle="Order Administrator" Address="Walserweg 21" City="Aachen" PostalCode="52066" Country="Germany" Phone="0241-039123" Fax="0241-059428" />
        <customers CustomerID="DUMON" CompanyName="Du monde entier" ContactName="Janine Labrune" ContactTitle="Owner" Address="67, rue des Cinquante Otages" City="Nantes" PostalCode="44000" Country="France" Phone="40.67.88.88" Fax="40.67.89.89" />
        <customers CustomerID="EASTC" CompanyName="Eastern Connection" ContactName="Ann Devon" ContactTitle="Sales Agent" Address="35 King George" City="London" PostalCode="WX3 6FW" Country="UK" Phone="(171) 555-0297" Fax="(171) 555-3373" />
        <customers CustomerID="ERNSH" CompanyName="Ernst Handel" ContactName="Roland Mendel" ContactTitle="Sales Manager" Address="Kirchgasse 6" City="Graz" PostalCode="8010" Country="Austria" Phone="7675-3425" Fax="7675-3426" />
        <customers CustomerID="FAMIA" CompanyName="Familia Arquibaldo" ContactName="Aria Cruz" ContactTitle="Marketing Assistant" Address="Rua Orós, 92" City="Sao Paulo" Region="SP" PostalCode="05442-030" Country="Brazil" Phone="(11) 555-9857" />
        <customers CustomerID="FISSA" CompanyName="FISSA Fabrica Inter. Salchichas S.A." ContactName="Diego Roel" ContactTitle="Accounting Manager" Address="C/ Moralzarzal, 86" City="Madrid" PostalCode="28034" Country="Spain" Phone="(91) 555 94 44" Fax="(91) 555 55 93" />
        <customers CustomerID="FOLIG" CompanyName="Folies gourmandes" ContactName="Martine Rancé" ContactTitle="Assistant Sales Agent" Address="184, chaussée de Tournai" City="Lille" PostalCode="59000" Country="France" Phone="20.16.10.16" Fax="20.16.10.17" />
        <customers CustomerID="FOLKO" CompanyName="Folk och fä HB" ContactName="Maria Larsson" ContactTitle="Owner" Address="Åkergatan 24" City="Bräcke" PostalCode="S-844 67" Country="Sweden" Phone="0695-34 67 21" />
        <customers CustomerID="FRANK" CompanyName="Frankenversand" ContactName="Peter Franken" ContactTitle="Marketing Manager" Address="Berliner Platz 43" City="München" PostalCode="80805" Country="Germany" Phone="089-0877310" Fax="089-0877451" />
        <customers CustomerID="FRANR" CompanyName="France restauration" ContactName="Carine Schmitt" ContactTitle="Marketing Manager" Address="54, rue Royale" City="Nantes" PostalCode="44000" Country="France" Phone="40.32.21.21" Fax="40.32.21.20" />
        <customers CustomerID="FRANS" CompanyName="Franchi S.p.A." ContactName="Paolo Accorti" ContactTitle="Sales Representative" Address="Via Monte Bianco 34" City="Torino" PostalCode="10100" Country="Italy" Phone="011-4988260" Fax="011-4988261" />
        <customers CustomerID="FURIB" CompanyName="Furia Bacalhau e Frutos do Mar" ContactName="Lino Rodriguez" ContactTitle="Sales Manager" Address="Jardim das rosas n. 32" City="Lisboa" PostalCode="1675" Country="Portugal" Phone="(1) 354-2534" Fax="(1) 354-2535" />
        <customers CustomerID="GALED" CompanyName="Galería del gastrónomo" ContactName="Eduardo Saavedra" ContactTitle="Marketing Manager" Address="Rambla de Cataluña, 23" City="Barcelona" PostalCode="08022" Country="Spain" Phone="(93) 203 4560" Fax="(93) 203 4561" />
        <customers CustomerID="GODOS" CompanyName="Godos Cocina Típica" ContactName="José Pedro Freyre" ContactTitle="Sales Manager" Address="C/ Romero, 33" City="Sevilla" PostalCode="41101" Country="Spain" Phone="(95) 555 82 82" />
        <customers CustomerID="GOURL" CompanyName="Gourmet Lanchonetes" ContactName="André Fonseca" ContactTitle="Sales Associate" Address="Av. Brasil, 442" City="Campinas" Region="SP" PostalCode="04876-786" Country="Brazil" Phone="(11) 555-9482" />
        <customers CustomerID="GREAL" CompanyName="Great Lakes Food Market" ContactName="Howard Snyder" ContactTitle="Marketing Manager" Address="2732 Baker Blvd." City="Eugene" Region="OR" PostalCode="97403" Country="USA" Phone="(503) 555-7555" />
        <customers CustomerID="GROSR" CompanyName="GROSELLA-Restaurante" ContactName="Manuel Pereira" ContactTitle="Owner" Address="5ª Ave. Los Palos Grandes" City="Caracas" Region="DF" PostalCode="1081" Country="Venezuela" Phone="(2) 283-2951" Fax="(2) 283-3397" />
        <customers CustomerID="HANAR" CompanyName="Hanari Carnes" ContactName="Mario Pontes" ContactTitle="Accounting Manager" Address="Rua do Paço, 67" City="Rio de Janeiro" Region="RJ" PostalCode="05454-876" Country="Brazil" Phone="(21) 555-0091" Fax="(21) 555-8765" />
        <customers CustomerID="HILAA" CompanyName="HILARION-Abastos" ContactName="Carlos Hernández" ContactTitle="Sales Representative" Address="Carrera 22 con Ave. Carlos Soublette #8-35" City="San Cristóbal" Region="Táchira" PostalCode="5022" Country="Venezuela" Phone="(5) 555-1340" Fax="(5) 555-1948" />
        <customers CustomerID="HUNGC" CompanyName="Hungry Coyote Import Store" ContactName="Yoshi Latimer" ContactTitle="Sales Representative" Address="City Center Plaza 516 Main St." City="Elgin" Region="OR" PostalCode="97827" Country="USA" Phone="(503) 555-6874" Fax="(503) 555-2376" />
        <customers CustomerID="HUNGO" CompanyName="Hungry Owl All-Night Grocers" ContactName="Patricia McKenna" ContactTitle="Sales Associate" Address="8 Johnstown Road" City="Cork" Region="Co. Cork" Country="Ireland" Phone="2967 542" Fax="2967 3333" />
        <customers CustomerID="ISLAT" CompanyName="Island Trading" ContactName="Helen Bennett" ContactTitle="Marketing Manager" Address="Garden House Crowther Way" City="Cowes" Region="Isle of Wight" PostalCode="PO31 7PJ" Country="UK" Phone="(198) 555-8888" />
        <customers CustomerID="KOENE" CompanyName="Königlich Essen" ContactName="Philip Cramer" ContactTitle="Sales Associate" Address="Maubelstr. 90" City="Brandenburg" PostalCode="14776" Country="Germany" Phone="0555-09876" />
        <customers CustomerID="LACOR" CompanyName="La corne d'abondance" ContactName="Daniel Tonini" ContactTitle="Sales Representative" Address="67, avenue de l'Europe" City="Versailles" PostalCode="78000" Country="France" Phone="30.59.84.10" Fax="30.59.85.11" />
        <customers CustomerID="LAMAI" CompanyName="La maison d'Asie" ContactName="Annette Roulet" ContactTitle="Sales Manager" Address="1 rue Alsace-Lorraine" City="Toulouse" PostalCode="31000" Country="France" Phone="61.77.61.10" Fax="61.77.61.11" />
        <customers CustomerID="LAUGB" CompanyName="Laughing Bacchus Wine Cellars" ContactName="Yoshi Tannamuri" ContactTitle="Marketing Assistant" Address="1900 Oak St." City="Vancouver" Region="BC" PostalCode="V3F 2K1" Country="Canada" Phone="(604) 555-3392" Fax="(604) 555-7293" />
        <customers CustomerID="LAZYK" CompanyName="Lazy K Kountry Store" ContactName="John Steel" ContactTitle="Marketing Manager" Address="12 Orchestra Terrace" City="Walla Walla" Region="WA" PostalCode="99362" Country="USA" Phone="(509) 555-7969" Fax="(509) 555-6221" />
        <customers CustomerID="LEHMS" CompanyName="Lehmanns Marktstand" ContactName="Renate Messner" ContactTitle="Sales Representative" Address="Magazinweg 7" City="Frankfurt a.M." PostalCode="60528" Country="Germany" Phone="069-0245984" Fax="069-0245874" />
        <customers CustomerID="LETSS" CompanyName="Let's Stop N Shop" ContactName="Jaime Yorres" ContactTitle="Owner" Address="87 Polk St. Suite 5" City="San Francisco" Region="CA" PostalCode="94117" Country="USA" Phone="(415) 555-5938" />
        <customers CustomerID="LILAS" CompanyName="LILA-Supermercado" ContactName="Carlos González" ContactTitle="Accounting Manager" Address="Carrera 52 con Ave. Bolívar #65-98 Llano Largo" City="Barquisimeto" Region="Lara" PostalCode="3508" Country="Venezuela" Phone="(9) 331-6954" Fax="(9) 331-7256" />
        <customers CustomerID="LINOD" CompanyName="LINO-Delicateses" ContactName="Felipe Izquierdo" ContactTitle="Owner" Address="Ave. 5 de Mayo Porlamar" City="I. de Margarita" Region="Nueva Esparta" PostalCode="4980" Country="Venezuela" Phone="(8) 34-56-12" Fax="(8) 34-93-93" />
        <customers CustomerID="LONEP" CompanyName="Lonesome Pine Restaurant" ContactName="Fran Wilson" ContactTitle="Sales Manager" Address="89 Chiaroscuro Rd." City="Portland" Region="OR" PostalCode="97219" Country="USA" Phone="(503) 555-9573" Fax="(503) 555-9646" />
        <customers CustomerID="MAGAA" CompanyName="Magazzini Alimentari Riuniti" ContactName="Giovanni Rovelli" ContactTitle="Marketing Manager" Address="Via Ludovico il Moro 22" City="Bergamo" PostalCode="24100" Country="Italy" Phone="035-640230" Fax="035-640231" />
        <customers CustomerID="MAISD" CompanyName="Maison Dewey" ContactName="Catherine Dewey" ContactTitle="Sales Agent" Address="Rue Joseph-Bens 532" City="Bruxelles" PostalCode="B-1180" Country="Belgium" Phone="(02) 201 24 67" Fax="(02) 201 24 68" />
        <customers CustomerID="MEREP" CompanyName="Mère Paillarde" ContactName="Jean Fresnière" ContactTitle="Marketing Assistant" Address="43 rue St. Laurent" City="Montréal" Region="Québec" PostalCode="H1J 1C3" Country="Canada" Phone="(514) 555-8054" Fax="(514) 555-8055" />
        <customers CustomerID="MORGK" CompanyName="Morgenstern Gesundkost" ContactName="Alexander Feuer" ContactTitle="Marketing Assistant" Address="Heerstr. 22" City="Leipzig" PostalCode="04179" Country="Germany" Phone="0342-023176" />
        <customers CustomerID="NORTS" CompanyName="North/South" ContactName="Simon Crowther" ContactTitle="Sales Associate" Address="South House 300 Queensbridge" City="London" PostalCode="SW7 1RZ" Country="UK" Phone="(171) 555-7733" Fax="(171) 555-2530" />
        <customers CustomerID="OCEAN" CompanyName="Océano Atlántico Ltda." ContactName="Yvonne Moncada" ContactTitle="Sales Agent" Address="Ing. Gustavo Moncada 8585 Piso 20-A" City="Buenos Aires" PostalCode="1010" Country="Argentina" Phone="(1) 135-5333" Fax="(1) 135-5535" />
        <customers CustomerID="OLDWO" CompanyName="Old World Delicatessen" ContactName="Rene Phillips" ContactTitle="Sales Representative" Address="2743 Bering St." City="Anchorage" Region="AK" PostalCode="99508" Country="USA" Phone="(907) 555-7584" Fax="(907) 555-2880" />
        <customers CustomerID="OTTIK" CompanyName="Ottilies Käseladen" ContactName="Henriette Pfalzheim" ContactTitle="Owner" Address="Mehrheimerstr. 369" City="Köln" PostalCode="50739" Country="Germany" Phone="0221-0644327" Fax="0221-0765721" />
        <customers CustomerID="PARIS" CompanyName="Paris spécialités" ContactName="Marie Bertrand" ContactTitle="Owner" Address="265, boulevard Charonne" City="Paris" PostalCode="75012" Country="France" Phone="(1) 42.34.22.66" Fax="(1) 42.34.22.77" />
        <customers CustomerID="PERIC" CompanyName="Pericles Comidas clásicas" ContactName="Guillermo Fernández" ContactTitle="Sales Representative" Address="Calle Dr. Jorge Cash 321" City="México D.F." PostalCode="05033" Country="Mexico" Phone="(5) 552-3745" Fax="(5) 545-3745" />
        <customers CustomerID="PICCO" CompanyName="Piccolo und mehr" ContactName="Georg Pipps" ContactTitle="Sales Manager" Address="Geislweg 14" City="Salzburg" PostalCode="5020" Country="Austria" Phone="6562-9722" Fax="6562-9723" />
        <customers CustomerID="PRINI" CompanyName="Princesa Isabel Vinhos" ContactName="Isabel de Castro" ContactTitle="Sales Representative" Address="Estrada da saúde n. 58" City="Lisboa" PostalCode="1756" Country="Portugal" Phone="(1) 356-5634" />
        <customers CustomerID="QUEDE" CompanyName="Que Delícia" ContactName="Bernardo Batista" ContactTitle="Accounting Manager" Address="Rua da Panificadora, 12" City="Rio de Janeiro" Region="RJ" PostalCode="02389-673" Country="Brazil" Phone="(21) 555-4252" Fax="(21) 555-4545" />
        <customers CustomerID="QUEEN" CompanyName="Queen Cozinha" ContactName="Lúcia Carvalho" ContactTitle="Marketing Assistant" Address="Alameda dos Canàrios, 891" City="Sao Paulo" Region="SP" PostalCode="05487-020" Country="Brazil" Phone="(11) 555-1189" />
        <customers CustomerID="QUICK" CompanyName="QUICK-Stop" ContactName="Horst Kloss" ContactTitle="Accounting Manager" Address="Taucherstraße 10" City="Cunewalde" PostalCode="01307" Country="Germany" Phone="0372-035188" />
        <customers CustomerID="RANCH" CompanyName="Rancho grande" ContactName="Sergio Gutiérrez" ContactTitle="Sales Representative" Address="Av. del Libertador 900" City="Buenos Aires" PostalCode="1010" Country="Argentina" Phone="(1) 123-5555" Fax="(1) 123-5556" />
        <customers CustomerID="RATTC" CompanyName="Rattlesnake Canyon Grocery" ContactName="Paula Wilson" ContactTitle="Assistant Sales Representative" Address="2817 Milton Dr." City="Albuquerque" Region="NM" PostalCode="87110" Country="USA" Phone="(505) 555-5939" Fax="(505) 555-3620" />
        <customers CustomerID="REGGC" CompanyName="Reggiani Caseifici" ContactName="Maurizio Moroni" ContactTitle="Sales Associate" Address="Strada Provinciale 124" City="Reggio Emilia" PostalCode="42100" Country="Italy" Phone="0522-556721" Fax="0522-556722" />
        <customers CustomerID="RICAR" CompanyName="Ricardo Adocicados" ContactName="Janete Limeira" ContactTitle="Assistant Sales Agent" Address="Av. Copacabana, 267" City="Rio de Janeiro" Region="RJ" PostalCode="02389-890" Country="Brazil" Phone="(21) 555-3412" />
        <customers CustomerID="RICSU" CompanyName="Richter Supermarkt" ContactName="Michael Holz" ContactTitle="Sales Manager" Address="Grenzacherweg 237" City="Genève" PostalCode="1203" Country="Switzerland" Phone="0897-034214" />
        <customers CustomerID="ROMEY" CompanyName="Romero y tomillo" ContactName="Alejandra Camino" ContactTitle="Accounting Manager" Address="Gran Vía, 1" City="Madrid" PostalCode="28001" Country="Spain" Phone="(91) 745 6200" Fax="(91) 745 6210" />
        <customers CustomerID="SANTG" CompanyName="Santé Gourmet" ContactName="Jonas Bergulfsen" ContactTitle="Owner" Address="Erling Skakkes gate 78" City="Stavern" PostalCode="4110" Country="Norway" Phone="07-98 92 35" Fax="07-98 92 47" />
        <customers CustomerID="SAVEA" CompanyName="Save-a-lot Markets" ContactName="Jose Pavarotti" ContactTitle="Sales Representative" Address="187 Suffolk Ln." City="Boise" Region="ID" PostalCode="83720" Country="USA" Phone="(208) 555-8097" />
        <customers CustomerID="SEVES" CompanyName="Seven Seas Imports" ContactName="Hari Kumar" ContactTitle="Sales Manager" Address="90 Wadhurst Rd." City="London" PostalCode="OX15 4NB" Country="UK" Phone="(171) 555-1717" Fax="(171) 555-5646" />
        <customers CustomerID="SIMOB" CompanyName="Simons bistro" ContactName="Jytte Petersen" ContactTitle="Owner" Address="Vinbæltet 34" City="Kobenhavn" PostalCode="1734" Country="Denmark" Phone="31 12 34 56" Fax="31 13 35 57" />
        <customers CustomerID="SPECD" CompanyName="Spécialités du monde" ContactName="Dominique Perrier" ContactTitle="Marketing Manager" Address="25, rue Lauriston" City="Paris" PostalCode="75016" Country="France" Phone="(1) 47.55.60.10" Fax="(1) 47.55.60.20" />
        <customers CustomerID="SPLIR" CompanyName="Split Rail Beer &amp; Ale" ContactName="Art Braunschweiger" ContactTitle="Sales Manager" Address="P.O. Box 555" City="Lander" Region="WY" PostalCode="82520" Country="USA" Phone="(307) 555-4680" Fax="(307) 555-6525" />
        <customers CustomerID="SUPRD" CompanyName="Suprêmes délices" ContactName="Pascale Cartrain" ContactTitle="Accounting Manager" Address="Boulevard Tirou, 255" City="Charleroi" PostalCode="B-6000" Country="Belgium" Phone="(071) 23 67 22 20" Fax="(071) 23 67 22 21" />
        <customers CustomerID="THEBI" CompanyName="The Big Cheese" ContactName="Liz Nixon" ContactTitle="Marketing Manager" Address="89 Jefferson Way Suite 2" City="Portland" Region="OR" PostalCode="97201" Country="USA" Phone="(503) 555-3612" />
        <customers CustomerID="THECR" CompanyName="The Cracker Box" ContactName="Liu Wong" ContactTitle="Marketing Assistant" Address="55 Grizzly Peak Rd." City="Butte" Region="MT" PostalCode="59801" Country="USA" Phone="(406) 555-5834" Fax="(406) 555-8083" />
        <customers CustomerID="TOMSP" CompanyName="Toms Spezialitäten" ContactName="Karin Josephs" ContactTitle="Marketing Manager" Address="Luisenstr. 48" City="Münster" PostalCode="44087" Country="Germany" Phone="0251-031259" Fax="0251-035695" />
        <customers CustomerID="TORTU" CompanyName="Tortuga Restaurante" ContactName="Miguel Angel Paolino" ContactTitle="Owner" Address="Avda. Azteca 123" City="México D.F." PostalCode="05033" Country="Mexico" Phone="(5) 555-2933" />
        <customers CustomerID="TRADH" CompanyName="Tradição Hipermercados" ContactName="Anabela Domingues" ContactTitle="Sales Representative" Address="Av. Inês de Castro, 414" City="Sao Paulo" Region="SP" PostalCode="05634-030" Country="Brazil" Phone="(11) 555-2167" Fax="(11) 555-2168" />
        <customers CustomerID="TRAIH" CompanyName="Trail's Head Gourmet Provisioners" ContactName="Helvetius Nagy" ContactTitle="Sales Associate" Address="722 DaVinci Blvd." City="Kirkland" Region="WA" PostalCode="98034" Country="USA" Phone="(206) 555-8257" Fax="(206) 555-2174" />
        <customers CustomerID="VAFFE" CompanyName="Vaffeljernet" ContactName="Palle Ibsen" ContactTitle="Sales Manager" Address="Smagsloget 45" City="Århus" PostalCode="8200" Country="Denmark" Phone="86 21 32 43" Fax="86 22 33 44" />
        <customers CustomerID="VICTE" CompanyName="Victuailles en stock" ContactName="Mary Saveley" ContactTitle="Sales Agent" Address="2, rue du Commerce" City="Lyon" PostalCode="69004" Country="France" Phone="78.32.54.86" Fax="78.32.54.87" />
        <customers CustomerID="VINET" CompanyName="Vins et alcools Chevalier" ContactName="Paul Henriot" ContactTitle="Accounting Manager" Address="59 rue de l'Abbaye" City="Reims" PostalCode="51100" Country="France" Phone="26.47.15.10" Fax="26.47.15.11" />
        <customers CustomerID="WANDK" CompanyName="Die Wandernde Kuh" ContactName="Rita Müller" ContactTitle="Sales Representative" Address="Adenauerallee 900" City="Stuttgart" PostalCode="70563" Country="Germany" Phone="0711-020361" Fax="0711-035428" />
        <customers CustomerID="WARTH" CompanyName="Wartian Herkku" ContactName="Pirkko Koskitalo" ContactTitle="Accounting Manager" Address="Torikatu 38" City="Oulu" PostalCode="90110" Country="Finland" Phone="981-443655" Fax="981-443655" />
        <customers CustomerID="WELLI" CompanyName="Wellington Importadora" ContactName="Paula Parente" ContactTitle="Sales Manager" Address="Rua do Mercado, 12" City="Resende" Region="SP" PostalCode="08737-363" Country="Brazil" Phone="(14) 555-8122" />
        <customers CustomerID="WHITC" CompanyName="White Clover Markets" ContactName="Karl Jablonski" ContactTitle="Owner" Address="305 - 14th Ave. S. Suite 3B" City="Seattle" Region="WA" PostalCode="98128" Country="USA" Phone="(206) 555-4112" Fax="(206) 555-4115" />
        <customers CustomerID="WILMK" CompanyName="Wilman Kala" ContactName="Matti Karttunen" ContactTitle="Owner/Marketing Assistant" Address="Keskuskatu 45" City="Helsinki" PostalCode="21240" Country="Finland" Phone="90-224 8858" Fax="90-224 8858" />
        <customers CustomerID="WOLZA" CompanyName="Wolski  Zajazd" ContactName="Zbyszek Piestrzeniewicz" ContactTitle="Owner" Address="ul. Filtrowa 68" City="Warszawa" PostalCode="01-012" Country="Poland" Phone="(26) 642-7012" Fax="(26) 642-7012" />
      </root>

    8. So...Now we have our database connection and we have some XML data that has at least one column (or in this case ALL columns :P) in common between them.  Let's whip up an interface!  Add a Button and a ListBox to your WebForm:

      image
    9. Double-click on your button to code for the Click Event:

      image
    10. The first thing we have to do is establish contexts to our data sources.  Put the following in your code:

      image
    11. Take a deep breath and get ready because we are about to jump off the proverbial cliff.  (pause)
      Okay, now let's begin our adventure into the LINQ query expression.  First we need to declare a variable to hold the results and, while we are at it, let's identify the elements in the XML file that we are interested in grabbing.
      (NOTE: if you need to, take another peek at the XML doc to remind you why we are pulling each "customers" element).

      image
    12. Next we need to indicate we want to join the XML data to the SQL data.  We do this with this line:

       image
    13. Now, there has to be some way to indicate how the XML data and the SQL data are connected.  Fortunately, they both have a CustomerID that allows us to link the different sets of data together.  Notice when we get the attribute we have to cast it as a string.  This is because, without the cast, the attribute reference would return an XAttribute type causing a type mismatch with the database's CustomerID.

      image
    14. Finally, we have to "catch" the data in a new anonymous object.  Just to prove the join is working we will catch a piece of data from each data source.  Also, to avoid confusion, let's slap some names on the return values.

      image
    15. So the final query should look like this:

      image
    16. Last, but not least, we need to iterate over the results and put them into our ListBox:

      image
    17. That's it!  When you run your code and click on the button you should wind up with something like the pic below:

      image

      Good times!! :)

    18. Technorati Tags: , , , , , ,
  • The Ultimate Visual Studio Tips and Tricks Blog

    Halo 3 Marches On

    • 1 Comments

    Yet another successful Halo 3 Event.  This time we were at the University of Texas at Austin.  Just for fun we not only did Halo 3 but had a PC gaming party at the same time. 

    PIC-0057

     

    So you could frag out with Halo 3

     

    PIC-0058 (2)

     

    Get crazy with Guitar Hero II

     

    PIC-0056

     

    Or just get crazy with your fav PC game.  Good times!! :)

     

  • The Ultimate Visual Studio Tips and Tricks Blog

    LINQ and Joins

    • 2 Comments

    Once again I was asked about LINQ and whether it supports joins or not.  The answer is NO.  Just kidding.  Of course it is YES.  We at Microsoft want to show you some LINQ Love (new term I have coined) and demonstrate how to do joins!  Yea!!!!!  (and there was much rejoicing)

     

    Here's what you need to get started:

    Visual Studio 2008 Beta 2

    SQL Server (any version, I'm using SQL Server 2005)

    An ant eater (okay, this last one is optional but they are really great if you have ants)

     

    Let's get started...

    1. Crank out a new web site and call it LINQ_JOIN_Fun.

      image

    2. Next, make sure you have a connection to some data source in your Server Explorer.  You may need to add a new connection. 

      image_thumb9
    3. For the purposes of this discussion I am using the Northwind Database on SQL Server. 

      image_thumb10
    4. Expand out the Northwind database and take a look at the tables.

      image
    5. So now we need to have our classes and mappings in place for using LINQ.  Fortunately, this is a VERY easy thing to do.  Just right-click your project, choose Project...Add New Item from the Menu Bar.  Let's add a "LINQ to SQL Classes" item with the default name of "DataClasses1.dbml".  If you get a funky message about putting it in the App_Code Folder just say yes. 

      image_thumb32 
    6. Click and drag the Customers, Orders, and Order Details tables from Server Explorer on to the LINQ design surface.

      image
    7. Rebuild the solution just to be safe so we are sure Intellisense is aware of what we just did.  Stirctly speaking this isn't required but it certainly helps sometimes. 
    8. Now let's add a button and a GridView Control to our WebForm.  Don't worry about the colors just yet on the GridView we are going to be doing that next.

       image
    9. Configure the GridView (in this case I'm assuming it is called GridView1) so that the DataSource stays at the default setting of "none" and then choose an AutoFormat that you like.  I am using "Sand & Sky" in this example.

      image
    10. Now comes the fun part.  We need to add some code in order to play with the data.  Double-click on the button to auto-magically wire up an Click Event.  You should see something like this:

      image
    11. The first thing we want to do is create our DataContext.  Since we may decide to use the same DataContext throughout the project, let's make it accessible to all the methods:

       image
    12. Inside our Button1_Click Event (or whatever your Click Event is called) we need to start building the LINQ query that will show us each OrderID from the Orders Table and the CompanyName of the company placing the order from the Customers Table.  The following figure shows all the columns from the Orders and Customers Tables:

      image

      Special Note:  In the NorhtWind Database these tables are called Orders and Customers respectively but when we put them on our LINQ-To-SQL design surface they are auto-magically made singular to bring them inline with common naming conventions used by developers. 
    13. Let's begin building our query expression.  We need to get our variable to hold the results out there and while we are at it let's identify the first table we want to pull data from (Orders in this case):

       image
    14. Next we need to join the Orders Table to the Customers Table.  Notice in Step 12 that they both have the CustomerID Column in common.  Here is how we would join Orders and Customers on CustomerID:

      image

      Special Note:  For the record, I am only showing an Inner Join here but LINQ is very capable of doing Outer Joins as well.
    15. Now let's put on the finishing touches to our expression.  We will most likely want to sort by OrderID and we will definitely need to indicate which pieces of information we want.  The following code uses an orderby to sort the info and the "new" keyword to create an anonymous object for each row.  Each object will contain the OrderID and the CompanyName:

      image
    16. Last, but not least, we need to set the DataSource of our GridView and then bind it:

      image
    17. That's it!  Run that puppy and see what happens.  If all is well, you should get some thing like this when you click on the button:

      image 

      So that's how you do a simple join using LINQ Query Expressions.  Stay tuned for more exciting adventures on this blog.


      RESOURCES

      LINQ Project on MSDN:  http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx

      LINQ-to-SQL Samples:  http://msdn2.microsoft.com/en-us/vbasic/bb688085.aspx



  • The Ultimate Visual Studio Tips and Tricks Blog

    LINQ and Stored Procedures

    • 18 Comments

    Okay so last quarter I was asked if you can call stored procedures using Language Integrated Query (LINQ).  The answer, of course, is YES!  It would be kind of silly if we didn't include this type of functionality. :P

     


    NOTE:  You need the following items to do this example

    SQL Server (pretty much any version will do but this example uses 2005)

    Visual Studio 2008 (Beta 2 was used for this example)

    A little time to sling some code

     

     

    So how exactly DO you call a stored proc using LINQ?  Easy just follow these simple steps:

    1. Create a new Windows Forms Application in Visual Studio 2008, let's call it "LINQ_SP_Coolness"

      image
    2. Next, make sure you have a connection to some data source in your Server Explorer.  You may need to add a new connection.

      image
    3. For the purposes of this discussion I am using the Northwind Database on SQL Server.

      image
    4. Take a look at the existing stored procedures because what you need may already be there.

      image
    5. Aaaaaand since I'm bored watching re-runs tonight, why don't we make our own stored procedure?

      image
    6. Just write a simple SELECT to yank out some data AND remember to save :)

      image
    7. Just to make sure, refresh the stored procedure folder on your data source in Server Explorer to see your shiny, new stored proc listed...

      image  
    8. You might even want to test it :P

      image
    9. To get this to a point we can manipulate it using LINQ we need to have our classes and mappings in place.  Fortunately, this is a VERY easy thing to do.  Just right-click your project, choose Project...Add New Item from the Menu Bar.  Let's add a "LINQ to SQL Classes" item with the default name of "DataClasses1.dbml".

      image
    10. Click and drag the stored procedure from Server Explorer on to the LINQ design surface.

       image
    11. You should see the procedure showing up on the upper right of the design surface.

      image
    12. Now let's slap some controls on our Windows Form.  How about a list box and a button?  Live on the edge!

      image 
    13. Now we need to work with database by establishing a context to it.  Next, we need to create a query expression that treats the result of the stored procedure as a table and query against it selecting only the LastName column.  Just for fun why don't we sort all the last names as well?  Finally, we will take the list of names returned and loop through them adding each one to our listBox as we go along.

      Double-click on the button to code for the Click event and write the following lines of code:
      (NOTE: make sure to substitute your server name in place of "zero_cool" and if you are using SQL Express you need to modify the server piece to read like this "SQLEXPRESS\myserver")

       image
    14. If all goes well, you should get the following result:

      image
    15. And that's how you use a stored procedure with LINQ.  This was a very simple example but if you really want to see a great series on LINQ go to my buddy Benko's site.   He has a webcast series on LINQ that kicks major butt! :)



      [Updated:  added tags]
  • The Ultimate Visual Studio Tips and Tricks Blog

    Where's Zain?

    • 2 Comments

    I know I haven't posted in a while.  I have been "soul searching" for an answer to how I can provide what the community needs through this medium.  Still looking for answers but plan to resume regular posting by the end of the month.

     

    Z

Page 126 of 135 (1,345 items) «124125126127128»