Grouping records in one single row
There are times when you need to group records which are linked by a common field (a foreign key) together into one single row. For example if you wanted to group all orders associated with a customer into one single row, it causes a problem in mysql because you can easily achieve a similar but yet different resultset by listing all the records associated with the foreign key.
There's something which you can use in MySql to group the results together, it's called the group_concat function. For values which are short, ...
MySQL Fulltext search problem
To enable fulltext search on a table inMySql, the following syntax is used:
ALTER TABLE your_table_name ADD FULLTEXT (Column_1, Column_2)
Fulltext on MySql will only work on MyISAM type tables.
You can issue a fulltext query as below:
SELECT * FROM your_table_name WHERE MATCH(Column_1, Column_2) AGAINST('your-search-query')
However for a small table with limited number of rows, you may not see the fulltext search results because of the following rule for fulltext:
"...words that are present in 50% or more of the rows are considered common and do not match"
To overcome this problem you can rewrite your ...
Configuring log4net
Tried Enterprise Library Logging Application Block but i'll have to say that log4net is easier and faster to use. So here's how to configure it. With the log4net.dll in your bin, you will need to open your web.config file and add the following line to your configSections node:
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
The after the </configSections> or anywhere else within <configuration>,
<log4net configSource="Config\log4net.config" />
Note: I store my log4net configuration as a separate xml file in a Config folder!
Your log4net.config file should look like this:
<!-- Logging related config options below this point -->
<log4net>
<appender ...
Turning identity off for a column in SQL Server
I'm currently moving my MySql database to SQL Server and for that reason i need to preserve the identity columns which i already have in the tables. Here's how it's done:
SET IDENTITY_INSERT tablename ON
SET IDENTITY_INSERT tablename OFF
So to insert the row ID=12, Name=Alfred, Age=23 in tblUsers, i would use the syntax below:
SET IDENTITY_INSERT tablename ON
INSERT INTO tblUsers (ID, Name, Age) VALUES (12, 'Alfred', 23)
SET IDENTITY_INSERT tablename OFF
You will need to turn the identity insert off so that SQL Server automatically generates the unique id for you afterwards.
Calculating x and y coordinates of an element in JavaScript
I was trying to get the Swazz calendar to work on Firefox but it would get displayed at the top on the webpage instead of showing up just under the textbox element which required the calendar values. So while debugging it i noticed that i had the the Transitional DocType on and it was messing around with it. I googled the problem and found that the solution was to 'px' to the value otherwise Firefox would ignore it.
getObj('fc').style.left=Left(ielem) + 'px';
getObj('fc').style.top=Top(ielem)+ielem.offsetHeight + 'px';
And this is how you get the coordinates with ...
Access to bin path denied in ASP.NET Web Application
Just downloaded a solution from Visual Source Safe and I was getting lots of errors due to references not being found. So I went through each project and removed the old references and replaced them with the new references. However when I finally came down to the web app, it would not compile because it was unable to copy dll to the bin because access to it was denied. I checked the properties for the bin folder and noticed that it was readonly. So I unchecked the readonly property and ...
Problem with SCOPE_IDENTITY() in ADO.NET
I'm using .NET 3.5, Visual Studio Team System 2008 and SQL Server 2005 and i'm trying to return the new id that is created after an INSERT statement. When i call ExecuteScalar, it returns zero. I've googled the problem and it seems that you need to cast the scope_identity to int before returning it.
Here are 3 solotions for the problem:
1. SELECT CAST(SCOPE_IDENTITY() AS INT) instead of just SELECT SCOPE_IDENTITY()
2. Declare a variable to hold the scope identity as follows:
DECLARE @NewID INT
SET @NewID = SELECT SCOPE_IDENTITY()
3. Have an output parameter in ...
View code not appearing in Visual Studio 2008
Another thing that I need to do is download the hot fix which addresses a couple of problems with Visual Studio 2008 Team Suite so that it can get rid of the annoying of having to go to the Solution Explorer to be able to "view code" in a Web Application rather than right clicking on an aspx page and selecting the "view code" option. The hot fix download is located below:
https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=10826
How to find out what access users have in Windows?
Many times you need to find out what access a particular windows user has and it's not very easy to get that information. I wanted to get a list of folders/directories to which a particular user (local user in windows) had access to so that i could debug an application. Luckily, i found about a small command line utility tool which enables you to do just that. You will need to download the AccessCheck program and use it to get the access report.
http://technet.microsoft.com/en-gb/sysinternals/bb664922.aspx
http://windowsitpro.com/article/articleid/97672/using-accesschk-to-view-which-files-and-folders-a-user-has-access-to.html
Integrating FCKeditor in my ASP.NET site
So I wanted to try FCKeditor in a website i was redesigning. The first problem i foresaw was that it didn't have an image resize option. However it seems to be the one closest to meet my requirements, therefore i'm thinking of hacking an image resize utility into the library.
As soon as i copied everything to my project, I got an HTTP Error 404 - Not found. I was like, what the hell just happened there, but then i googled the problem and find the solution. You need to specify ...