Wednesday, January 27, 2010

Dictionary on C#

this will get a mapping for values of page names and attach the resource to redirecto to each value.

string previousPage = Request.QueryString["Src"];
string DP = Request.QueryString["DP"];
var dictionary = new Dictionary();
dictionary["AccountingDetail"] = "AccountingDetail.aspx?DP="+DP;
dictionary["Fixing"] = "Fixing.aspx";
dictionary["Payment"] = "Payment.aspx";

if (dictionary.TryGetValue(previousPage, out pageMap ))
{
Response.Redirect(pageMap );
}

and here is the data format when you want to pass a datetime value in de parameters of an url from a source page:

DataNavigateURLFormatString="MyPage.aspx?product={0}&category={1}&date={2:d}"





Thursday, January 7, 2010

update with join from a table with one field


To update a field from other table were we want one that field and we know there is a join.


update tableA
set Email = b.email
from tableA a inner join tableAbkp b on a.UserName = b.Username
where b.UserName not like '%user01%'

so here is an example to do the trick


orphan childs in tsql

Sometimes when we restore a db we include a user on it and it might be as well available at the server we are restoring. Sometimes the user stays orphan so you can't access the database even if you have the same user as the login on the server. Here's a quick workaround for it.

to see wich users are orphan:
sp_change_users_login @Action='Report';

to perform the action:

sp_change_users_login @Action='update_one', @UserNamePattern='',
@LoginName='';

hope this helps .