Author Archives: Aron

Finding column info for a table

Ran across this little gem while working on some integrations, really comes in handy.

SELECT 
    c.name 'Column Name',
    t.Name 'Data type',
    c.max_length 'Max Length',
    c.precision ,
    c.scale ,
    c.is_nullable,
    ISNULL(i.is_primary_key, 0) 'Primary Key'
FROM    
    sys.columns c
INNER JOIN 
    sys.types t ON c.system_type_id = t.system_type_id
LEFT OUTER JOIN 
    sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id
LEFT OUTER JOIN 
    sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
WHERE
    c.object_id = OBJECT_ID('Candidate')

New blue tooth keyboard

image

I just got a new blue tooth wireless keyboard for use with my tablet.  I like it, it allows me to enter information to it a hell of a lot faster than the on screen keyboard.  So far I like it but as you can see it’s a little small but I think that I can adjust to it…

Clearing a drop down list value on a web form

Ran into this issue with trying to clear a data linked drop down list on a web form, it was tricky because there are two controls for the drop down list, the first one being the ‘source’ and the second one being the sub-source. All I had to do was clear the source by using the following line:

ddlSource.SelectedIndex = -1;

Writing form data to SQL DB with C#

In having to convert my current VB projects into C#, I ran into an issue trying to write to a DB from a form.  This blog opened my eyes to how this is accomplished and here is the code I used to get the unsubscribe feature to work.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace Taleo_UnsubscribeJPN
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DateTime tstamp = DateTime.Now;
String email = Request.QueryString["email"];
String atsid = Request.QueryString["atsid"];
lblEmail.Text = email;

}

protected void btnRemove_Click(object sender, EventArgs e)
{
String strBrowserInfo = (Server.HtmlEncode(Request.UserAgent));
String strIPAddress = (Server.HtmlEncode(Request.UserHostAddress));
String atsid = Request.QueryString["atsid"];
string connection_string = "Data Source=DB_Server;Initial Catalog=TaleoData;Persist Security Info=True;User ID=tdowner;Password=password";
string query = "insert into OptOutEmail (email, tstamp, processed, atsid, remote_addr, http_user_agent) values ('" + lblEmail.Text + "', '" + DateTime.Now + "', " + 0 + ", '" + atsid + "', '" + strIPAddress + "', '" + strBrowserInfo + "')";
SqlConnection connection1 = new SqlConnection(connection_string);

SqlCommand insertCommand = new SqlCommand(query, connection1);

connection1.Open();

insertCommand.ExecuteNonQuery();

connection1.Close();

Server.Transfer("Confirmation.aspx?email=" + lblEmail.Text);

}
}
}

Binding https Protocol to 2 Sites with Host Headers

I almost didn’t know what the hell to title this post because it’s almost too obscure to understand.  Here’s the skinny:

I’m having to move our DNN site from a server that is on life support (win2k3/IIS6/32bit) to a brand spanking new VM (w2k8/IIS7/64bit).  Sounds like fun doesn’t it?  Well the main problem is that the default web site is DNN but we also have to host an unsubscribe form so if you don’t want job notices you just click remove and we stop sending notices.  Should be nice and easy to set up host headers to catch this.  And if works fine and well if you just want to do it on port 80.  But god forbid you want to use host headers for SSL.  You have to use the appcmd.exe from the command line to do this.  Now I have no idea how it works but here is what did the trick for me and binding the unsubscribe site to SSL with host headers:

appcmd set site /site.name:”unsubscribe” /+bindings.[protocol=’https’,bindingInformation=’*:443:unsubscribe.pdstech.com’]

And just a note I found on technet, even if you are running a 64bit server don’t use the exe from the syswow64 directory, so much for consistancy MSFT:)

Finding Size of Tables in MSSQL Database

I was trying to explain to my boss that the SQL database we’re using for the intranet was somewhere in the 400 MB range when he asked ‘What’s taking up all the space?’  I was a little taken aback, I mean databases collect data and that takes up space right?  Well it got me thinking what the hell is taking up all the space.  I found this great query that tells all:)

</pre>
SELECT
 t.NAME AS TableName,
 i.name AS indexName,
 SUM(p.rows) AS RowCounts,
 SUM(a.total_pages) AS TotalPages,
 SUM(a.used_pages) AS UsedPages,
 SUM(a.data_pages) AS DataPages,
 (SUM(a.total_pages) * 8) / 1024 AS TotalSpaceMB,
 (SUM(a.used_pages) * 8) / 1024 AS UsedSpaceMB,
 (SUM(a.data_pages) * 8) / 1024 AS DataSpaceMB
FROM
 sys.tables t
INNER JOIN
 sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
 sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
 sys.allocation_units a ON p.partition_id = a.container_id
WHERE
 t.NAME NOT LIKE 'dt%' AND
 i.OBJECT_ID > 255 AND
 i.index_id <= 1
GROUP BY
 t.NAME, i.object_id, i.index_id, i.name
ORDER BY
 OBJECT_NAME(i.object_id)
<pre>

Oracle Data Provider for ASP.NET Windows 2008 R2 x64

Being an integration engineer can be frustrating at times to say the least.  Oracle in my opinion doesn’t play too well with Microsoft but I did find the data access components I needed to make my reporting work.  It’s here on Oracles site.  Iused the 64bit ODAC 11.2.Release 4 (11.2.0.3.0) Xcopy for Windows x64.  Extract and follow the instruction in the readme file and cross your fingers and spin around 3 times for luck.  It can’t hurt when dealing with Oracle products:)

Security issue when upgrading DNN

I ran into a security issue when updating DNN on a work server.  Basically once you put the files in place they don’t have the permission to do the upgrade.  Oddly enough I found this little gem that explained how to do the following:

Run the below caspol command to resolve the issue Drive:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url “file:////c:\mysitecontent\*” FullTrust -exclusive on

Note: Please substitute “c:\mysitecontent\*” with actual path where ASP.net pre compiled dlls are located.

I’ve also had to use the stacks method called in this blog.

Unable to prepare the SSIS bulk insert for data insertion

Minor point of annoyance to keep in mind, always run BIDS as administrator otherwise you’ll get some jacked up errors, Microsoft wrote an article about it here.

Installing Fedora Core 16 from USB

So as I’ve said we’ve been replacing all the computers here at work and that’s lead to a plethora of spare computers, I mean it’s to the point of overflow as even I am looking at them all wondering what the hell to do with them all.

So I was on Staples site the other day and found the coolest thing, it’s a hot swap bay that you can use to read all the data on those 40 gig drives that are multiplying around here like Tribbles.  Then it occurred to me that I could use it to format each of the half dozen 40 gig drives with a different OS.  Whoo Hoo we have achieved nerdvana!!!  A different OS every week and just label the drive with what’s on it.  True greatness.  In any case FC16 is going to be the first and here is how you make an installation USB for it from the good folks over at fedoraproject.org:

  1. Download the LiveUSB Creator program for Windows from http://fedorahosted.org/liveusb-creator.
  2. Either: click the Browse button under the Use existing LiveCD label, browse to the location where you previously downloaded a Fedora Live ISO file, and select that file.
    select a Fedora Live ISO file from the drop-down menu that LiveUSB Creator presents under the Download Fedora label. Note that image files are large and that it is probably impractical to use LiveUSB Creator to download an image file if you do not have a broadband connection to the Internet.
  3. Click Create Live USB.