Posts

Showing posts from 2010

Create a rich image link in 5 simple steps

Image
Even some well designed sites make minor usability faux pas. Let’s look at the homepage of Commotion Creative, as I saw it on October 19, 2010, to be more specific, at the Featured Projects section. The links look nice but they do not change their state whatever action you take – hover over or click (image below).


As a user, I expect these links to have three states (something like in the image below):
InactiveHovered overActive (Pressed)Here is a quick recipe how to make a link respond to the user’s actions, with an image and a few CSS styles.
Add an image link, that is an IMG tag nested into an A tag:
<a href="#"><img src="square.png" /></a>
Remove the border around the image:
a img {border-width:0;}
Add the three styles for the A tag:
a {background-color:#dadada;padding:7px;display:block;width:91px;height:81px;}
a:hover {border:1px solid #555;padding:6px;}
a:active {border:7px solid #555;padding:0;}
To make it work under Mozilla and WebKit, provide …

CREATE DATABASE (SMO)

Create a SQL Server Database by using SMOIn this small tutorial I will show you how to create a database with SMO and C# in Visual Studio 2008. I will use a Console application.
Prerequisites:SQL Server 2005 is installedVisual Studio 2008 is installedCodeAssembliesYour C# project must reference:
SystemSystem.DataMicrososft.SqlServer.ConnectionInfoMicrososft.SqlServer.Management.Sdk.SfcMicrososft.SqlServer.SmoNamespacesThe source class file must use:
SystemSystem.Data.SqlClientMicrososft.SqlServer.Management.CommonMicrososft.SqlServer.Management.Smoclass ConsoleSmo {   public static Main()   {     string connLocal = "Data Source=(local); Integrated Security=SSPI;"SqlConnection connection = newSqlConnection(connLocal);     Server server = newServer(newServerConnection(connection));     Database db = newDatabase(server, “TestDb”);     db.Create();     connection.Close();   } } ExplanationsThis code opens the connection to the server and produces the Server object. Next, it creates…

CREATE DATABASE (T-SQL)

Create a SQL Server Database using T-SQLYour need to create a database by using T-SQL. The simplest command you can issue to achieve this is:
CREATE DATABASE <database_name>If you open the database, you will notice that its metadata has been set to some values and perhaps, the database already contains tables, stored procedures, UDFs and other objects. How does this magic work? Actually, the SQL Server derives a new database from the model database. Below is how MSDN explains this process:
All user-defined objects in the model database are copied to all newly created databases. You can add any objects, such as tables, views, stored procedures, data types, and so on, to the model database to be included in all newly created databases.When a CREATE DATABASE database_name statement is specified without additional size parameters, the primary data file is made the same size as the primary file in the model database.Unless FOR ATTACH is specified, each new database inherits the databas…

CREATE DATABASE (ADO.NET and C#)

Create a SQL Server Database ProgrammaticallyYou need to create a SQL Server database programmatically by using ADO.NET and C#. Here is a quick recipe how to do that.
using System; using System.Data.SqlClient; SqlConnection localConn = newSqlConnection ("(local); Integrated security=SSPI; database=master"); string SQLCommand = "CREATE DATABASE TestDb"; SqlCommand DbCreate = newSqlCommand(SQLCommand, localConn); try { localConn.Open(); DbCreate.ExecuteNonQuery(); Console.WriteLine("DataBase is Created Successfully"); } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); } finally { if (localConn.State == ConnectionState.Open) { myConn.Close(); } } This code creates a database similar to the SQL Server Model database and places its files to the default location. If you want to create a database with custom properties, please check out MSDN.