| Fiach's profileNetwork Programming in ....BlogLists | Help |
|
March 24 SQL performance: Nested select statements.This is a tip for restructuring nested select statements to make them run faster in SQL server. I can't vouch for this in all situations, but It shortened a long SQL query for me from 1 hour to 7 minutes.
Where you have
Select * from xyz where id in
(
Select * from abc where id in
(
select id from def
}
)
I recommend re-writing as
Select * into #abcdef from abc where id in
(
select id from def
}
Select * from xyz where id in
(
select id from #abcdef
) March 23 Charset reverting to Windows standardOn Internet eplorer 6 SP1, If you perform a Response.Flush() before any content goes to the page, then the charset will revert to Windows. Regardless if the charset is set in the HTML.
If you put this line in Page_load, it should fix the problem
Response.Charset = "UTF-8"; March 22 Differences between CHOICE command in Batch filesBatch files may be arcane, but they serve well for quick & nasty build scripts. One point to note that I fell into a trap today is the difference in the implementation of the CHOICE command (prompting the user for input) between Windows 9x and Windows 2000/XP. - Alot of documentation on Batch files is quite old, and thus doesn't mark any difference
Windows 9x:
CHOICE /C:123 /N Please choose a menu option.
IF ERRORLEVEL == 3 GOTO LIVE IF ERRORLEVEL == 2 GOTO BACKUP IF ERRORLEVEL == 1 GOTO LOCAL EXIT Windows 2000/XP:
set choice=
set /p choice=Please choose a menu option. if not '%choice%'=='' set choice=%choice:~0,1% if '%choice%'=='1' goto LOCAL if '%choice%'=='2' goto BACKUP if '%choice%'=='3' goto LIVE EXIT March 19 Google Toolbar buttons... second attemptI tried to put together some google Toolbar buttons. However, there is something wrong with the icons. It seems to work ok for the 32x32 16 colour icon, but not the 24x24 true color + alpha icon. Must look more into this...
--------------------------------
----------------------
http://toolbar.google.com/buttons/add?url=http%3A%2F%2Fwww.webtropy.com%2fw%2fbuymusiccd.xml ---------------------------------
http://toolbar.google.com/buttons/add?url=http%3A%2F%2Fwww.webtropy.com%2fw%2ffindpeoplefreecouk.xml ----------------------------
http://toolbar.google.com/buttons/add?url=http%3A%2F%2Fwww.webtropy.com%2fw%2flistofbuildersinfo.xml
etc. etc.
March 18 Transparent LocalisationI've just launched one website, in four different languages all in the same path, with the same files & database under IIS.
www.sms-txt.co.uk (english)
www.handyspruche.com (german)
www.envoyezsms.com (french)
www.mensajetexto.com (Spanish).
How did I do it?
public static string getGetSiteCulture() { string strUrl = System.Web.HttpContext.Current.Request.Url.ToString().ToLower(); string strCulture = "en-GB"; if (strUrl.IndexOf("mensajetexto")!=-1) {strCulture = "es-ES";} if (strUrl.IndexOf("handyspruche")!=-1) {strCulture = "de-DE";} if (strUrl.IndexOf("envoyezsms")!=-1){strCulture = "fr-FR";} return strCulture; }
Then I have 4 different Resource files, strings.es-ES.resx, strings.en-GB.resx etc. public static string Translate(string ID){ rmTranslations.IgnoreCase = true; string strTranslation ="";Thread.CurrentThread.CurrentCulture = new CultureInfo(getGetSiteCulture());Thread.CurrentThread.CurrentUICulture = new CultureInfo(getGetSiteCulture()); try{strTranslation= rmTranslations.GetString(ID);} catch{ throw new Exception(ID + " not found");} return strTranslation;}
Then in place of static text, I put Translations.Translate("Whatever") March 17 Parsing Skylights Route informationA company which develops airline websites, known as SkyLights, has a common format for javascript which they place on their webpages to populate two dynamic drop down lists for their routes.
This can be parsed out of the page, using this c# code
// var aVCE = new Array('TXL','HAM','HAJ','CGN','STR', 0); string[] strlines = Regex.Split(tbEntry.Text,@"\n"); string strOutput = ""; foreach(string strLine in strlines){ string strFromIata = Regex.Match(strLine,@"a(\w{3})\s").Groups[1].Value;MatchCollection mcIatas = Regex.Matches(strLine,@"'\w{3}'"); foreach(Match mIata in mcIatas){ strOutput+="'" + strFromIata + "'," + mIata.Value + "\r\n"; } } tbEntry.Text = strOutput; March 14 Google Toolbar buttonsWith the new version of Google toolbar, you can add your own buttons to it, with quite a simple technique.
Step 1.Create an .ico file,
Step 2. Base 64 encode it :
FileStream fsIco = new FileStream(tbIco.Text,FileMode.Open); byte[] bIco = new byte[fsIco.Length];fsIco.Read(bIco,0,( int)fsIco.Length); this.tbOutput.Text = Convert.ToBase64String(bIco);fsIco.Close();
Step 3: Create an XML file containing the encoded icon
<?xml version="1.0" encoding="utf-8" ?>
step 4. Host the xml file on line - I called it slashdot_button.xml Then let people download it from http://toolbar.google.com/buttons/add?url=http%3A%2F%2Fwww.cheapflights.ie%2Fslashdot_button.xml
March 08 "Cannot open SQL server" bug Crystal ReportsThis one baffled me for a while. I was trying to connect to a Crystal Report from VB, with an Access database. And it was giving me a "Cannot open SQL server", even though I was not using SQL server.
Under Database / Add Database, you have several options to add an access database,
eithe ODBC, OLEDB or Database File.
I found that Database File worked, the other two didn't. This could be down to the
connection string that I used in my program though.
March 04 IT clearoutHi,
I'm clearing out my house of some books and equipment, prob. going to list them on ebay soon. If you're interested in any of these, drop a note on the blog or by email.
http://www.blackcomb.co.uk/pics/040306_0912~00.jpg xml web services
http://www.blackcomb.co.uk/pics/040306_0912~01.jpg network programming in Windows
http://www.blackcomb.co.uk/pics/040306_0912~02.jpg Developing windows based applications in c#
http://www.blackcomb.co.uk/pics/040306_0913~00.jpg Java network programming
http://www.blackcomb.co.uk/pics/040306_0913~01.jpg SQL weekend crash course
http://www.blackcomb.co.uk/pics/040306_0916~00.jpg USB ADSL modem
http://www.blackcomb.co.uk/pics/040306_0917~00.jpg portable CD/MP3 player
http://www.blackcomb.co.uk/pics/040306_0918~00.jpg PCMCIA USB adapter
http://www.blackcomb.co.uk/pics/040306_0918~01.jpg Net2Plug power cable home networking kit.
http://www.blackcomb.co.uk/pics/040306_0911~00.jpg inkjet printer Fiach |
|
|