Posts
119
Comments
115
Trackbacks
22
Wednesday, July 01, 2009
workspaces in sql mgmt studio
How is it that you still can't save workspaces in SQL Server Management Studio as of version 2008?  It seems like such a simple thing to implement.  Quite often I create a bunch of different queries during a short period that are specific to a task I'm working on and that won't be needed once the task is completed, and rather than having to save each one it would be nice if I could just save a workspace file that knows which queries were open.
posted @ Wednesday, July 01, 2009 10:46 AM | Feedback (0)
Tuesday, June 09, 2009
attaching adventureworks2008 on full version of sql server
For anybody that bought the SQL Server 2008 Self-Paced Training book for 70-433, if you are running a full version of SQL Server 2008 rather than the express edition, you will have problems attaching the AdventureWorks2008 database (file activation error).  The trick is to use a SQL command, like so:

 
USE [master]
GO
CREATE DATABASE [AdventureWorks2008] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\AdventureWorks2008_Data.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\AdventureWorks2008_Log.ldf' ),
 FILEGROUP Documents CONTAINS FILESTREAM (NAME = Documents, FILENAME=N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\Documents')
 FOR ATTACH
GO
posted @ Tuesday, June 09, 2009 12:39 PM | Feedback (3)
Wednesday, April 15, 2009
sharepoint 2007 (moss) system account

I spent the past day trying to figure out why I couldn't log in as myself, Sharepoint would always just say I was logged in as System Account.  After a ton of research and changing things I ran into this:

To fix this, you must run the following commands: stsadm -o updatefarmcredentials -identitytype NetworkService

followed by: iisreset

http://social.technet.microsoft.com/Forums/en-US/sharepointadmin/thread/8d8d9b30-0995-47ba-96e8-7b52872664f3

That solved my problem.  I'm using NTLM authentication and I set up a new Active Directory user called sharepointuser to be the identity for the app pool (changing the app pool from myself to that user probably helped, but that isn't what fixed it ultimately).  I'm pretty sure if I had set up sharepointuser before I installed MOSS 2007 on the Windows 2003 server and specified that user during the installation, I wouldn't have had the auth problems to begin with.

posted @ Wednesday, April 15, 2009 7:40 AM | Feedback (0)
powershell cut and paste

Here's a Powershell script I whipped up to copy all bak files from C:\TEMP to Y:\DEST.  It checks to make sure the file is present at the destination before it deletes it from the source.  I placed it in a ps1 (the extension for Powershell files) file and scheduled a task to execute a batch file that executes the ps1 file.  The reason I had to check for null is that Powershell is kinda dumb and if the source folder is empty it picks it up as a child and performs the Copy-item.

$oldPath = "C:\TEMP"
$newPath = "Y:\DEST"
$GciFiles = get-childitem $oldPath

foreach ($file in $GciFiles){
  Write-host $file.Name
  if(!($file.Name -eq $null) -and $file.Name.EndsWith(".bak")){
      Write-host "copying item "+($newPath+'\'+$file)
      Copy-item $oldPath\$file $newPath
      if (Test-path ($newPath+'\'+$file)) {
          Write-host "removing item "+($oldPath+'\'+$file)
          Remove-item ($oldPath+'\'+$file) -recurse
      }
  }
}

posted @ Wednesday, April 15, 2009 4:57 AM | Feedback (0)
Thursday, April 09, 2009
ajax loader in user control within master page

I spent hours trying to figure out why my ASP.Net page, which uses a master page with a RadGrid surrounded by a RadAjaxPanel with an AjaxLoadingPanel, would not show the loading message.  I would click on the link to the page in the site menu, then IE would sit and spin for a while until it loaded the entire page, rather than loading the page right away but showing the loading spinner until the data was returned.  What I had to do was add this javascript (w/jQuery) to the user control that the grid was in:

<script type="text/javascript">
    $(document).ready(function() {
        setTimeout(loadGrid, 500);       
    });

    function loadGrid() {
        window['<%=RadAjaxPanel1.ClientID %>'].AjaxRequest('');
    }   
</script>

I'm not sure why I had to make it sleep for half a second, but it wouldn't work until I added that.

I set up a server-side event (OnAjaxRequest="RadAjaxPanel1_AjaxRequest") that fires when AjaxRequest is called in the javascript:

protected void RadAjaxPanel1_AjaxRequest(object sender, AjaxRequestEventArgs e) {
 Presenter.InitializeView();
 BindGrid();
}

posted @ Thursday, April 09, 2009 4:58 AM | Feedback (0)
Monday, March 02, 2009
comcast blocking port 25?
Even though the email server I'm running at home only sends and receives around 10 emails per month and has never been open for relay, it seems as though Comcast has started blocking port 25.  The technician I've chatted with says otherwise, but either he was wrong or not telling the truth.  I'm just putting that out there in case others have the same problem.
posted @ Monday, March 02, 2009 8:23 AM | Feedback (4)
Tuesday, February 10, 2009
tinyint surprise
I just discovered something rather surprising.  If you return a tinyint from a stored procedure as part of a dataset, and bind that dataset to a dataview, and then do something like this:

<asp:Label runat="server" id="statusLabel" Text='<%# GetStatusText( (int)DataBinder.Eval(Container, "DataItem.status")) %>'>
</asp:Label>

You will get an error about an invalid cast.  If the stored procedure returns an int instead of tinyint, it works just fine.  How can ASP.Net 3.5 not be able to cast from a tinyint (or whatever its C# equivalent is) to an int??
posted @ Tuesday, February 10, 2009 1:05 PM | Feedback (0)
Tuesday, February 03, 2009
resharper clean-up gotcha
Be careful when using Cleanup Code on a web solution in Visual Studio.  It may change the Inherits string in your Global.asax file in order to remove unnecessary namespaces, which apparently are actually necessary for the site to start up.
posted @ Tuesday, February 03, 2009 7:34 AM | Feedback (0)
Thursday, August 07, 2008
resharper and auto-property gotcha

Be very careful when allowing Resharper to convert properties to auto-properties.  In some cases it will re-initialize fields that were already initialized earlier on in the constructor.

 

http://www.jetbrains.net/jira/browse/RSRP-75137;jsessionid=D915EE10CA08D52D70BCAD44AE37447B?page=com.atlassian.jira.plugin.system.issuetabpanels:changehistory-tabpanel

posted @ Thursday, August 07, 2008 11:10 AM | Feedback (0)
Wednesday, August 06, 2008
generic typing and scope_identity()

I recently ran into an interesting problem.  I had created a data access method that used generic typing to execute a scalar SQL Server stored procedure (below), and in the stored procedure was returning SCOPE_IDENTITY() for an integer identity column.  I was passing in a type of "int" to the method (as <T>) since that's what I was expecting back, but I kept getting back null.  After some frustration and bewilderment I discovered that SCOPE_IDENTITY() always returns a decimal, and C# doesn't want to convert the decimal to an integer automatically.  I worked around it by using CAST in the stored procedure so that I didn't have to modify the method.

 

        private static T? ExecuteScalarStoredProcedure  (string sprocName, SqlParameter[] parameters) where T : struct {

            SqlConnection conn = new SqlConnection(GetConnectionString());

            conn.Open();
            object retValue;
            try {
                SqlCommand command = new SqlCommand(sprocName, conn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddRange(parameters);

                retValue = command.ExecuteScalar();
            }
            finally {

                try {

                    conn.Close();

                }
                catch (Exception) {
                    //Ignore close exception
                }
            }
            return retValue as T?;
        }
posted @ Wednesday, August 06, 2008 5:38 AM | Feedback (0)
Friday, June 27, 2008
best quote ever

"So they told me that using the download page to download something was not something they anticipated."

--Bill Gates 

posted @ Friday, June 27, 2008 11:07 AM | Feedback (0)
Wednesday, May 28, 2008
activerecord and executereader exceptions

About once a day I was getting the following error from an ASP.Net web page that uses ActiveRecord:

Exception Details: System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

I would subsequently get this error upon refreshing the page:

Exception Details: System.InvalidOperationException: ExecuteReader requires an open and available Connection. The connection's current state is closed.

I finally figured out that the problem occurs when the database is restored.  The connections in the IIS application pool do not get destroyed when the database is restored, so when ActiveRecord (nHibernate) tries to reuse the connections it fails.  This doesn't happen to me when I'm not using ActiveRecord, so I'm not sure if this is a bug with ActiveRecord or a problem with the way I've set up the data access layer.

posted @ Wednesday, May 28, 2008 8:46 AM | Feedback (0)
Friday, April 25, 2008
band names for programmer geeks

Band names for programmer geeks (feel free to use these, unless they already exist and are copyrighted):

  • Asskey
  • The Lazy Loaders
  • CMYK (more for graphic artists, I know)
  • nRock
  • BSODeathmetal
  • Unicoder Manifesto
  • Fist to Five
  • Gates of Hell (that one's for Microsoft programmers specifically)
posted @ Friday, April 25, 2008 12:45 PM | Feedback (0)
Thursday, April 17, 2008
if geeks ruled the world

If geeks ruled the world:

  1. Professional sports teams, if they existed, would have mascots like the Orcs, the Elves, and the Supernovae. The Giants and the Pirates could keep their names, and possibly the Blue Devils (though due to statistical improbability, Duke would not be allowed to be in the Sweet 16 so often).
  2. All surnames would have to be pronounced as they are in their country of origin (e.g. Favre would be Fov-ruh and Mao Tse-Tung would be unpronounceable).
  3. Wars would occur between the cybergeeks and the envirogeeks. The weapons would consist of twenty-sided dice and solar-powered Laser Tag guns.
  4. There would be KSL programs (Klingon as a Second Language).
  5. I would be a very high-ranking officer!
posted @ Thursday, April 17, 2008 4:15 AM | Feedback (2)
Thursday, April 10, 2008
ssas: define reference and materialize

Apparently you have to watch out when you select Materialize in a referenced dimension in SSAS 2005.  I just ran into a situation where data was getting duplicated for no good reason, and unchecking Materialize fixed it.

http://www.biblogs.com/2006/12/23/materialize-option-in-a-reference-dimension/

posted @ Thursday, April 10, 2008 10:25 AM | Feedback (0)
News