Posts Tagged ‘Programming’

Jul
06/09
C# Missing References
Last Updated on Monday, 6 July 2009 05:08
Written by snapjag
Monday, July 6th, 2009

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.

Tags: , , , , ,   |  Posted under Programming  |  Comments  No Comments
Sep
19/08
.NET and MySQL
Last Updated on Sunday, 19 April 2009 08:17
Written by snapjag
Friday, September 19th, 2008

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 mysql-connector-net-5.2.1.zip) 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
Tags: , , ,   |  Posted under Database, News, Programming  |  Comments  No Comments