Posts tagged ‘new programmer’

March 11, 2011

ASP.NET Membership Provider Part 1

ASP.NET has a membership provider built-in that can be used to authenticate and manage the users who will be visiting your website. These features can be used to determine if a user viewing the website is authenticated or anonymous and to display content according to who is viewing the page. There are also controls for creating new users, changing passwords, and logging in.

Creating The Database

In order to use the ASP.NET membership provider you will need to create a database. The membership tables can either be part of the application’s database or it can be its own database.

Integrating the membership tables with your application’s database has a few benefits such as being able to create foreign keys between the membership tables and your own. However, creating the membership tables in their own database will allow multiple website to use the same database for authentication.

To crate the tables and store procedures navigate to Start –> All Programs –> Microsoft Visual Studio XXXX –> Visual Studio Tools –> Visual Studio Command Prompt.

Enter the command aspnet_reqsql to start the ASP.NET SQL Server Setup Wizard

Figure 1

Figure 1: Visual Studio Command Prompt

After the wizard has started click next.

Figure 2

Figure 2: ASP.NET SQL Server Setup Wizard

Select “Configure SQL Server for application services.”

Figure 3

Figure 3: ASP.NET SQL Server Setup Wizard

Enter the server’s name and credentials if necessary. Also select the database where the ASP.NET membership tables and stored procedures should be created.

Figure 4

Figure 4: ASP.NET SQL Server Setup Wizard

Verify the entered information is correct and click next. Then click finish.

Figure 5

Figure 5: ASP.NET SQL Server Setup Wizard

The tables and stored procedures for ASP.NET Membership have now been added to the selected database.

Configuring The Application

The next step is to configure the application’s web.config file.

First setup your connection string to the database. If you created the ASP.NET Membership tables in a separate database you will need to create two connection strings.

Figure 6

Figure 6: Connection String Settings

Now we need to change the authentication mode to forms and set the login URL for the web site.

Figure 7

Figure 7: Authentication Settings

Next we need to setup the membership settings.

Note: The application name setting is used when multiple websites use the same database for authentication.

Figure 8

Figure 8: Membership Settings

Moving Forward

Your database and website are now configured to use the built in ASP.NET membership provider. In part 2 I will discuss the controls(login, register, validation) built into ASP.NET to take advantage of the membership provider.

March 10, 2011

New Programmer: User Groups Are Your Friend

One of the issues I’ve noticed with student developers is their lack of practice in their art. This is understandable, considering you always have to start somewhere and build a foundation, and that can be very scary. Just as musicians must listen to and learn from other musicians (say, guitarists eyeing the Eagles’ Joe Walsh), developers need to listen and learn to other developers. Local user groups are a great way to do this, and usually without costing a dime.

What User Groups Offer

User Groups offer you the ability to chill out with people with the same interests and exchange ideas, ask and answer questions, and be surrounded by those who are like you. If you’re trying to learn how to code in Java, hanging out at McDonald’s isn’t going to do it. Going to a Java User Group, usually called a JUG, is where you’re going to learn to hone your craft. User Group meetings usually have some sort of topical presentation, then breakout sessions for specific topics, such as Web development, mobile development, and database solutions.

Finding User Groups

There are many resources out there to help you find a user group. Bing and Google are your friends, especially since there aren’t usually more than a handful of groups per topic per capita. So, starting with search engines is a good place to begin. It should be as easy as entering your nearest major city and the topic plus the term user group. Additionally, many of the developer user groups are part of a larger user group movement across the world, so I would look for <City Name> + <User Group Type You’re Looking For>, such as:

  • Indianapolis .NET User Group
  • Bay Area SQL Users Group
  • Boston PHP User Group

Some of these groups have particular nomenclature for themselves, such as Java User Groups being named JUGs. So, the following chart may help as well when crawling through search results:

  • Indiana + Windows User Group = I + WUG = IWUG
  • Indiana + Linux User Group = L + WUG = LWUG
  • Indiana .NET Developer Association = Indy + NDA = IndyNDA
  • Indiana Java User Group = Indy + JUG = Indy JUG
  • Indy + SQL Association = Indy PASS
  • Indy + Alternative to .NET-Only User Groups = Indy ALT.NET

A number of industry organizations have formed and make available lists of user group meeting locations. Some of these organizations include INETA, SQL PASS, GITCA, Java User Group (JUG) Community, image

You may also want to check out APCUG, the Association of Personal User Groups. While I’m not sure they’re as popular as they were in the 80s and 90s, they may still be able to help.

Still other ways to find user groups include platform Web sites, such as Microsoft’s Web site, the Java Web site and others… they usually have a support and/or resources section for finding gathering grounds for like minds.

Find Friends in Your Field (a.k.a. “Networking”)

Another opportunity presented by user groups is the ability to network, which is the act of finding people who can help achieve your mutual goals. If you’re a student looking for an internship, you’re much more likely to find people willing to bring you on if you’re regularly attending user groups than if you just outright search for internships.

Perception is reality – if you’re attending groups with people who know their stuff, other people in those groups will start to believe you know your stuff as well. It sure is easier to land an internship or a job if you’re a known quantity.

Moving Forward

It’s easy to get disheartened when starting in software development. There are a lot of people who know more than you. But all those people started where you are today. Those same people are willing to help you get better, possibly better than them! It’s always best to surround yourself with and learn from people who know more than you. It keeps things real, and makes you a better developer.

Additional Resources

Obviously Bing and Google are your friends when it comes to finding info on the Web. Some of the links below may also help you quickly find a user group resource:

February 14, 2011

New Programmer Skill: Option Strict

When first learning how to program it is important to concentrate on the basics and learn the correct way to avoid falling into bad habits that will be hard to break down the road. Since you are new to programming you will most likely not know all the correct ways to write code, so it’s nice to have something like Option Strict there to teach (or remind) you what is correct.

Why Use Option Strict?

When Option Strict is set to on, it will not allow the implicit narrowing conversions without the use of an explicit cast.

In this example, vb.net allows me to set a double equal to an integer. If we were to run this example, dblCost would have a value of 39.95, but intCost would only have a value of 39. This occurs because the data type double can handle decimal places, while the integer data type cannot. The compiler tries the conversion, but the result is the wrong result.

After enabling option strict in the same example you would receive an error like:

By changing Dim intCost As Integer = dblCost to Dim intCost As Integer = Convert.ToInt32(dblCost), we have fixed the error message given by the VB.NET compiler. While this fixes the compiler error message it doesn’t fix the incorrect logic because after converting 39.95 to an integer explicitly the value will still be 39.

Since we enabled Option Strict we would see this error as a compiler error. If Option Strict were not on this error would most likely not have been caught until an angry customer noticed they are not receiving the correct values and hours could be wasted debugging the program to find the error.

Enabling Option Strict

By default Option Strict is set to off to allow conversions from Visual Basic 6 to VB.NET. So it will have to be enabled manually and this can be accomplished in one of three ways.

Option 1: Enabling in code.

You can add the following line of code to each of your code behind pages.

Option 2: Enable Option Strict for entire project.

To enable option strict for the entire project, simply right-click on the project in question -> click properties -> select Compile and change Option Strict to on.

Option 3: Set Option Strict as default for all project.

To enable option strict as the default for all projects, click tools -> click options -> select VB Defaults under Project and Solutions and turn Option Strict On.

Moving Forward

Using Option Strict is a great way to improve your programming skills and know how. If you plan on moving to another language like C# it is a good idea to use Option Strict while developing in VB.NET because you will not have the option in C#. So do yourself a favor and use Option Strict while you can because it won’t always be there.

January 27, 2011

New Programmer Skill: Why Debugging Is So Important

by Auri Rahimzadeh, President, The Auri Group

When things go wrong with code, you need to be able to find the bug quickly. The process for hunting down and killing bugs is called “debugging.” These days it’s incredibly easy to debug, making your job as a programmer much easier. I will spare you the history lesson on how debugging was done when I was growing up 🙂

read more »