WebsiteSpark Program for Noobies and Small Businesses

Microsoft has been moving at lightning speed to give software away. Especially to web professionals that want to make a huge difference in their new start-up career.  They may actually be on their way to provide a great stimulus package, that’s what I think. When Microsoft decides to give away thousands of dollars of software for free, you should perk up and listen. WebsiteSpark is a participation program you will not want to look past. Continue reading

Dreamspark Opportunity Extended

The opportunity for students just got a little sweeter. It used to be that under the Dreamspark program, college students wanting to get their feet wet in programming, could signup for the program and receive some of Microsoft’s flagship programming applications for free! Yes, free! When did Microsoft ever offer something for free. Well, they got close … it is free … however, they simply want to make sure the offer is being provided to the right market group. Students.

The sweet spot just hit by offering this now not to just College students, but now High School students. In the grades from 9 through 12. The “very small” catch is that the students must go through a few “small” hoops to get it.  I would highly advise that anyone in school from grade 9 to college look into this … it’s great. The students in High School will need to have the assistance of a school representative to make the requests, download the keys, and download the software for the student, but that’s a small price to pay for the really small price to start getting into programming.

C# Missing References

If you are getting an error like “The type or namespace name does not exist in the namespace” you may have found yourself tweaking the references or the using statements in your C# code.

The using statement and the referencing statement differ in that the using statement is a logical link and reference to the namespace library, this makes it so you can shorten your qualifications to objects. Instead of typeing System.Windows.Forms.Textbox. You place a using statement “using System.Windows.Forms” at the top of your page and you only have to now use the word Textbox to reference the object. These are also usually statements to libraries within your current namespace.

The References are registrations to libraries and dlls that are to be used outside your namespace.

Recently in a project, there were a number of projects that had change adding some ENUM references that were prominently used in the application. These errors made it immpossible to build the solution. In order to rid yourself of this error, you must resolve a conflict, or supply a reference or using statement.

First, check the statement where the error occurs. Make sure the namespace/library that the object refers to is available in the project. If you find the source cs file, look to see if the Namespace is different than where the object is being used. If they are different, then either fully qualify the namespace in front of the object, or add the “using <full namespace>;” statement at the top.

Try and compile the application, if you still have the error, then look in the current project (where the error occurs) References list and see if the assembly/library is there. It’s it isn’t, then add the new Reference by either locating the .NET object, COM object, project, or file.

When this has been added, try compiling again. If you still get the error, then you’ll have write some comments here and provide your code for me to be able to help you further.

Using properties in an Web Control

When creating a web control in an application many times you will need to make references to information, data values and other contents of the web control from the web control parent. This is done by adding a Property statement on the control. It could be as simple as a Username and Password control to set or get the information at times of requesting login details.

Follow these steps to connect and use data on the User Web Control:

  1. Create a new Web Control in your application project
  2. Place two label and two textboxes on the control
  3. Name the two controls txtUsername and txtAddress
  4. In the code behind of the control add the following code (C#)private string username = String.Empty;
    private string password; = String.Empty;
  5. public string Username {
    get { return username; }
    set { set username = value; }

    public string Password{
    get { return password; }
    set { set password; = value; }

  6. Close the control designer windows, saving all changes
  7. Open the web page that will use the control
  8. Drag and drop the new web control onto the web page canvas (if you already had the web control on your webpage and you added new interface elements (public functions or properties), you will likely need to remove the controls including the REGISTER statements at the top of the page so that the interface elements are reconnected to the page for you.
  9. In the code behind the web page, make any references to the Tag name of the control (assuming “uc1” in this case) using the following statements (C#).this.uc1.Username = “Your username”;
    this.uc1.Password{ = “Your password”;

This concludes the tutorial to add a simple web control and connect to it from the parent web page where it resides. This concept will help in many ways like, login pages, bread crumbs, contained lists, or other user interface lists.

C# GridView rows not vertically aligned

A recent project caused me grief until it dawned on me what the problem and the fix was. The GridView has a height property value and if it’s changed from the default (which is NULL), or to anything less than 25px (arbitrary number) you may experience an undesierable result where the GridView will vertically align the rows in the middle of the control. I did this inadvertantly, creating this undesireable result, and I wanted to share with you the fix and why does this. Continue reading

SMO SQL Server Error Reading Stored Procedures Collection

The following error is appearing while running Visual Studio 2005 and developing an application with SMO capabilities. It appears when trying perform a foreach( on ActiveDB.StoredProcedures).

Could not load file or assembly ‘Microsoft.SqlServer.BatchParser, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

I found an MSDN article that recommends downloading the 64 bit SMO assembly. Continue reading

.NET DataGridView Edit Pencil Icon

There’s a problem when editing the DataGridView.

Problem: The pencil glyph icon in edit mode wouldn’t go away. Here’s the situation and the solution.

Solution: If the property Virtual is set to false the glyph will go away, period.

Even after doing this, a call to the EndEdit() function wasn’t required to make the glyph go away even though other people say that it’s required. Test it though to make sure. Suffice it to say that if you’re still having a problem after setting the Virtual property, then it’s something with the grid property settings or the programmatic overrides you’re doing. But this setting worked for me.

Any additional comments or concerns about this?

Visual Studio DataGridView

An application I wrote to compare values in the rows of two datagridviews, set side-by-side, will hide rows if no difference is found; which then leaves just the rows that are different. Simple enough, but an error was thrown when one of the grid’s cells was active. This is the error.

Row associated with the currency manager's position cannot be made invisible.

The solution is to put the following command somewhere at the top of your routine before accessing the grid rows (C# code).

<DataGridView>.CurrentCell = null

Hope this helps.

.NET and MySQL

Searching for a document that helps to connect a .NET web application with MySQL is hard to find. So, I thought I would provide instructions I put together while developing my own applications.

The .NET infrastructure is very flexible and is easier to use than people think. Here are the steps that I went through to get everything working and connected. Because I program in C# this tutorial is presented in that language. This is an outline of the process and steps to accomplish this tutorial. It helps to keep the ideas in check and that there are no missing subjects.

  1. Install MySQL v5.0
  2. Install Visual Studio (use the express editions if you don’t have full versions)
  3. Install the MySQL 5.0 .NET Data Connector v5.2 (for example or other connector of your programming choice.
  4. Start building a database
    1. A nice application to use is ModelRight 3 community edition
    2. Create two tables and add some fields and join one of the tables to the other in a parent-child relationship
    3. Generate (engineer) the database to MySQL
  5. Open Visual Studio
  6. Go to the Server Explorer, right-click on Data Connections
  7. Click Add Connection
  8. Change the datasource to MySQL Database and make sure the Data provider is .NET Framerwork Data Provider for MySQL and click OK
  9. Login to the server with the following:
    1. Server name: localhost
    2. User name: root
    3. Password: the initial password you gave when setting up MySQL
    4. Database name: This is the name of the database you will attach to. It’s possible you haven’t set one up yet, see the Building a MySQL Database below.
  10. Create a website application using Visual Studio (File | New | Website)
  11. Pick ASP.NET Web Site (or ASP.NET AJAX-Enabled Web Site) if you have the .NET AJAX Toolkit installed.
  12. Add the connection string to Web.Config
  13. Update App_Code data layer classes to use the schema of the database
  14. Add an Object Data Connection to the web page with the following settings
  15. Put a DataGridView on the screen and connect it to the Object Data Connection object with these settings
  16. Run the application