Advertise here


Tag cloud


 

Posts Tagged ‘useful script’

Console C# getting database connection string from app.config file

Posted on Monday, November 1st, 2010 in Top Tips

When writing a console application using C# / .NET and you want to connect to a database, the connection string is typically stored in the app.config file. Below is an example of a web.config which is the same an app.config file used in C#.Net. It is essentially an XML file that stores required data to make your application work. It keeps these bits of data in one place, making it easy to manage when things change. There will be no need to hunt down connection strings or other configuration data with in your application code.

To extend further on this top tip I have written a tutorial on how to use CSharp with MySQL.

 <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
       <ConnectionString>
         <add key="MySQL.DB" value="server=localhost;database=mysqldbname;user=username;password=12345678;" />
       </ConnectionString>

       <system.web>
        <compilation defaultLanguage="c#" debug="true" />
      </system.web>

    </configuration>

To access the connection string the first step would be to make sure that a reference is added to System.Configuration. Then make sure you include it in the class using System.Configuration and the code below is used to access the connection string.To access the connection string the first step would be to make sure that a reference is added to System.Configuration. Then make sure you include it in the class using System.Configuration and the code below is used to access the connection string.

using System.Configuration;

string MysqlConnectionString = ConfigurationManager.ConnectionStrings["dbconnectionstring"].ConnectionString;

This method can also be used to access the app.config file for any web applications.


Hiding rows in a table using JQuery

Posted on Thursday, October 28th, 2010 in JavaScript

I was writing a simple JQuery script which filters out table rows based on class name.  When I used visibility:hidden; I noticed that when it was made visible again, the table looked slightly broken. To fix this instead of using visibility:hidden use visibility:collapse; and this keeps the table format correct when it is made visible again.
Read more


Remove link border when clicked

Posted on Thursday, October 28th, 2010 in Top Tips
CSS Top Tip

How to get rid of the dotted border around a link when it has been clicked.

a {
    outline: 0;
}

JQuery AJAX Query creator

Posted on Monday, June 7th, 2010 in JavaScript

This is a useful script that I have written that uses the JQuery library, so don’t forget to include it above this script. It collects all the form data from all the different form types and formats into a query string to pass through the AJAX method (JQuery or your own). It behaves in the same way as the GET method for example if a checkbox is not selected the data is not sent and it can filter which radio form has been selected. Read more


Format styles for standard HTML elements

Posted on Sunday, June 6th, 2010 in CSS

icon for CSS articlesBelow is a small and simple CSS style sheet for formatting all HTML elements.

This will improve cross browser compatibility and create consistency through your web site. Especially when you have designed a site for a client and they have chosen to maintain it, who knows what tags they will use. This will hopefully prevent the client from have odd looking bits on their site. Read more



Web Design Essex | Richard Kotze – Web Technology, Design and Development powered by WordPress | Entries (RSS)