Thursday, February 21, 2008

web.config debug="false"

I think we should change all the live sites' web.config with debug="false". It's both insecure and inefficient to leave debug="true" on a live site based on these two articles:
http://weblogs.asp.net/scottgu/archive/2006/04/11/442448.aspx
http://networking.itbusinessnet.com/articles/viewarticle.jsp?id=135133

If we remember to do that every time we publish a site, we might be able to use that info to tell if it's from test site or live site.

Ignore settings in TortoiseSVN

Hey guys, 

Just wanted to check in and see that everyone has this stuff set in their TortoiseSVN Settings. Does anyone have something different than shown in this pic?

Thursday, February 14, 2008

sqlbulkcopy

I have just used sqlbulkcopy for the third or so time. This is a handy thing built into 2.0 that you should be familiar with. In the past I have used it in my code to copy a row into an "archive" table before deleting it from the initial table. Today I used it to copy data to a database housed at another school. I had a copy of their schema. I built a view of our data, such that the view held just what needed to go into their table. Here is my sample code:


string sql = "SELECT * FROM sourceView";
using (SqlConnection conn = new SqlConnection(dsn))//source dsn
using (SqlCommand cmd = new SqlCommand(sql, conn))
using (SqlBulkCopy copy = new SqlBulkCopy(dsn2))//destination & source dsn are the same
{
conn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
copy.DestinationTableName = "destinationTable";
//have to map the columns because the tables are not an exact match
copy.ColumnMappings.Add("fieldname", "samefieldButSlightlyDifferentName");
copy.ColumnMappings.Add("fieldname2", "samefieldButSlightlyDifferentName2");
copy.WriteToServer(rdr);
conn.Close();
}


A couple things to note. I copied code from the last time I did this. Reading my comment I'm not sure I actually needed to map out the columns, because from my view to the destination the schemas matched up. Last time I did this however, there were a few more columns in the destination table, hence my comment about the not matching up. Second, I got this error early on: SqlBulkCopy: the locale id '0' of the source column ' ' and the locale id '1033' of the destination column '' do not match. This was because the ID column in my table was an int and in theirs was varchar. I therefore modified my view for that and one other column so that the data types matched using CAST(field as varchar) AS field.

Wednesday, February 13, 2008

firesizer

Guys,
I've tried out and like a new extension for Firefox. It's the third of its kind that I have tried & so far I like it the best. It's just a window resizer, but this one integrates into the status bar so no menu interaction is needed to access it, and it keeps your current size available for you in the status as well. Nice! Here is a link: https://addons.mozilla.org/en-US/firefox/addon/5792