ASP.NET from Scratch: SQL Server
videos

ASP.NET from Scratch: SQL Server

Tutorial Details
  • Difficulty: Intermediate
  • Length: 35 Minutes
This entry is part 4 of 10 in the ASP.NET from Scratch Session
« PreviousNext »

Part four of this series changes the lesson plan again! This lesson introduces you to Microsoft SQL Server 2008 and SQL Management Studio. Youíll learn how to create a database, add tables to it, and populate it with data. You’ll then use that data and bind it to a template control.


Lesson 4: SQL Server


Sell ASP.NET Components on CodeCanyon

Did you know that you can sell your ASP.NET scripts and components on CodeCanyon? Simply sign-up for a free author account, and start selling!

Jeremy McPeak is jwmcpeak on Codecanyon
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://twitter.com/xrommelx xRommelx

    really cool, i hope to learn so much from this video

  • er

    Great job explaining this I see a lot of folks struggle on how best to present data in .NET apps.

  • Nick

    Really awesome video, just like any others in this course… Do you know when we can expect the next one? I’m hungry for more :)

  • Bretticus

    Excellent tutorial! I do miss the power of data binding controls in .Net (mostly a Unix shop these days.) Very clear and concise. Especially for programmers who may never have used VS before. Great job!

  • http://sonergonul.com Soner Gönül

    Wow

    That’s cool

    Thanks

  • http://ds.laroouse.com piyanistll

    really cool, i hope to learn so much from this video

  • http://sonergonul.com Soner Gönül

    I want on this video Microsoft .NET blue wallpaper :)

    Where can i find it ?

    • http://www.wdonline.com Jeremy McPeak
      Author

      I made it for the series. I’ll see if I can locate the PSD.

    • http://www.wdonline.com Jeremy McPeak
      Author

      I found it and uploaded it to http://www.wdonline.com/dotnet_wp.zip. It’s 1024×768, but it’s easy enough to make for a higher resolution.

  • http://www.jeffadams.co.uk Jeff Adams

    I’ve come from VB to classic ASP, and now these days I dabble with MySQL and PHP for anything database related – the sole reason is because I was missing this exact video lol.

    Brilliant. Really looking forward to the the rest in the series – can we have some classic database interactions for us geeks!!! ???

    • http://www.wdonline.com Jeremy McPeak
      Author

      Straight-up ADO.NET was originally planned for this lesson. I don’t think we’ll see plain ‘ol ADO.NET in this series, but there will probably be an article on it sometime.

  • http://www.freshclickmedia.com Shane

    Good stuff for people new to ASP.NET/SQL Server. Just a few really small points:

    1) sa is an acronym for Server Administrator (not super admin, as you say.)
    2) I’m surprised you didn’t wrap your Page_Load code in

    if( !Page.IsPostBack).

    3) I’m glad you used those literal controls – lots of people I have worked with use asp:Label (which generates an often unnecessary span tag if the AssociatedControlID attribute is not set.)
    4) The ItemDataBound method is a method, true, but more specifically, it’s an event handler.
    5) I often use the ItemDataBound to do simple class hooking onto the alternate row (rather than copying and pasting the ItemTemplate markup, I can get away with not using the other template. This is especially useful if the markup is complicated (and the row/alternate row differ only by a class name.)
    6) In your ItemDataBound event, your two literals will only be NOT null in an item or alternating item row. A more usual check often precedes your code, using the RepeaterItemEventArgs argument:

    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    // do what’s needed with the literals in here:
    }

    Overall, though – good to see ASP.NET stuff on here.

    • http://www.wdonline.com Jeremy McPeak
      Author

      Thanks, Shane. To address your points:

      1. I’ve never found the official name for sa. I’ve seen it referred to as System Admin, Server Admin, and Super Admin. I use super admin as a holdover from my MySQL days.

      2. No need to in this example.

      3. I see that often, too.

      4. It can go either way depending on your point of view. To me, it’s first and foremost a member of the _Default class. It couldn’t handle any event if the method didn’t exist within a class first.

      5. I typically shy away from doing that. If I have to revisit the app a few months down the road, or if a coworker has to look at it to fix a bug, I think it’s easier for the maintainer to get a grasp of what’s going on if the templates are used the code-behind just feeds the data to the control. That’s just my preference, though.

      6. That is a better way, especially if a server control with the same name and type were used in the header, footer, orseparator templates. The way presented in the video would result in a NullReferenceException if a Literal control with the name ltlLastName was in a non-Item template.

      • http://www.freshclickmedia.com Shane

        Thanks for the response Jeremy. You’re right about point 2 – I suppose I do data-binding so often in that conditional, I would always put it there anyway (though yes, you don’t need it in this example since you’re not doing any postbacks.)

        Point 4 – sure, it’s a member of the _Default class, but it’s also an event handler, for that event, on that repeater. :)

        Point 5 – Sure – everybody has their own way of doing things – I often put a server-side comment in the markup to alert me or somebody else that there’s some jiggery-pokery going on in the code-behind (for the reason you mention.)

        Point 6. I often put that check in, since it alerts other people working on the code that I’m only expecting to find those controls in that specific row item type.

  • http://thx2madre.tistory.com Irene

    Good job. I hope 2 learn so much :)

  • http://www.alanagius.com Alan

    Great article, thanks.

  • http://njedesign.com Norm

    Nice job!!!

    Hope to see more .net and sql server screen casts.

  • http://davidgoldberg.me/ David

    Very useful. Plenty of corporate firms use ASP.NET and tutorials like these can help to broaden the skill set for people looking to learn.

  • Sunny

    How come this video is not on iTunes?

  • http://bloggerzbible.blogspot.com/ Bloggerzbible

    thanks for the tut

  • http://www.softter.com/ Norm Evans

    Thanks for providing such a great and helpful information and video for asp.net and sqlserver.

  • Neil

    In example 3, if you really wanted showcase “separation of concerns” you could subscribe to the ItemDataBound event in the code-behind:

    protected void Page_Init(object sender, EventArgs e)
    {
    rptNames.ItemDataBound += new RepeaterItemEventHandler(rptNames_ItemDataBound);
    }

    I like to keep all my events in the code-behind, especially if there are buttons, data binding events, selected index changes etc..

  • http://www.sqllion.com SQL Lion

    T-SQL RowNumber() vs Rank() vs DenseRank() vs NTILE() | SQL Lion
    SQL Server comes with some magical words that make simple the life of a developer or DBA to a great extent. And these magic words are RowNumber(), Rank(), DenseRank() and NTile(). Follow the link to get more…
    http://www.sqllion.com/2010/07/ranking-functions/

  • RCDMK

    Hello!
    Just to say this video is broken.

  • Black

    Please fix the video

  • stefan24

    Please can you host the .mov version of this? I’ve checked the site / the members site and itunes but can’t find it. Any chance of throwing up a link?

    Cheers
    Stefan

  • Vicky

    unable to view this video (ASP.NET from Scratch: SQL Server).
    It is saying Sorry, Unable to play this episode…
    Please i want see this episode.

  • sandy

    hello all,

    To learn .net what basic languages i should learn before i start.

  • Vasanth

    Very Good Screen cast.

  • Yoosaf Abdulla

    Hi Jeremy,

    The tutorial as you might have heard 100 times is superb :-).

    However I am facing issue in casting the container method with Linq object to display data in the repeater. I get the error saying that the namespace ‘TemplateControls’ is not identifiable. They say to import the correct directive or assembly.

    Being specific:

    Compiler Error Message: CS0246: The type or namespace name ‘TemplateControls’ could not be found (are you missing a using directive or an assembly reference?)

    I am running a VS2010 with 3.5 framework.

    Please help.

    Thanks,
    Yoosaf Abdulla

    • Yoosaf Abdulla

      Hi Jeremy,

      It was my bad, the namespace spelling was wrong. Thanks Jeremy for the fantastic tutorials. It is really cohesive and helped me lot in understanding concepts such as:

      1. Private variables
      2. Getter/Setters
      3. Interfaces (this is a ‘bingo’)

      I really appreciate your efforts and thank the Plus network.

      Regards,
      Yoosaf Abdulla

  • Philly Guy

    These tutorials definitely do have value and Jeremy is certainly to be commended for doing them. However, having gotten this far (I’m still watching this episode), I must say that he assumes an enormous amount of prior knowledge as he breezes through his demonstrations. This leaves me feeling very disappointed and as if I’m going to have to find a way to fill in the gaps somewhere else. There are many examples of this until now, but for example just now, what in the the world is this “n” in the “db.Names.OrderBy(n => n.LastName)”? Where does it come from? How does it work? Why does it work? Why does it work with “.LastName”? What does “n =>” mean in this context and why is it necessary? Why can’t it just be simple, e.g., “orderby(lastname)” or similar? Why doesn’t Jeremy explain these things and seem to assume they make sense or perhaps that people already know them? And prior to that in this vid, why in the world does “Names” become “Name” when you add the linq to sql class to begin with? Why does it work. I’m sorry but I just feel the gushing praise here is a bit hasty, and someone who is just trying to make a transition from Access to .NET there are many gaps here that leave me feeling like not enough is being explained in these vids, even though as I said they are still valuable, and certainly very helpful to some extent. So thanks much for the extent to which they are.

    • Philly Guy

      Yes, I know what “=>” means, but in this context I’m looking for something more fundamental, as in why does it have to be so needlessly complicated in such a totally nonintuitive way compared to using VBA code? The “n” just came out of nowhere here, as did the singular “name” earlier.

    • Philly Guy

      Actually, I just realized – no, I do not even know what “=>” means. I was thinking of “>=” instead. I appreciated from the beginning that Jeremy was going to spend time presenting essentials, and thought that was a great idea after looking at other CBT vids, but it is important to explain the things one does present as if they are new to the learners and to equip them to then do it on their own in an understanding way rather than by rote.

    • Philly Guy

      Still reviewing this vid when I get around to it. People seriously need a reality check…squared. The “literal” method on the ItemTemplate – you know, the one that is so lovely in keeping with the idea of keeping one’s server code out of the UI page – is so absurdly complicated, convoluted, loooooong, and complex, one is hard pressed to perceive what is so great about .NET when it has to be like that just to populate a table with data compared to what you can do in something more intuitive, “sense-making,” and far more straightforward by comparison like Office VBA, for example. At least for this particular need, so absurd and abstruse.

      • Philly Guy

        What in the world were they thinking?

      • Philly Guy

        Oh, and I’ll take the data binding syntax, thank you, if it means avoiding all that mind boggling “literal” code in the code behind. The former is convoluted enough already.