Subscribe to Alvin Poh's Blog by RSS reader
Subscribe to Alvin Poh's Blog by Email
Gadgets, Technology, Public speaking and IT from an undergraduate's perspective.
How To Create a Stored Procedure using C#, SQL Server 2008, Visual Studio 2008
Microsoft’s Visual Studio 2008 is amazing. It truly is an integrated development environment, because EVERYTHING is integrated. I just learnt about stored procedures today and how creating stored procedures is so easy in Visual Studio. Here’s the steps that you need.
- In Visual Studio, create a solution if you haven’t, and to that solution, add a project of the type “SQL Server Project”
- Next, right click on that project (not the solution) and add an item of the type “Stored Procedure”, and choose “Stored Procedure” as the sub-type that we want.
- You should see the stored procedure added to your project as a file. I’m using C#, so it’s added as a new C# file, with some template code added already.
- Try adding this code chunk:
SqlPipe p = SqlContext.Pipe;
p.Send(”Hello!”); - Now we can test out our new stored procedure by right-clicking on the project and selecting “Deploy”. This will create a DLL file and copy it over the SQL Server.
- Open up SQL Server Management Studio and click on the button titled “Create a New Query’. You should see a screen pop up on the right.
- Enter this code:
USE [YourDatabaseName]
GO
EXEC [dbo].[WhatYouNamedYourStoredProcedure]
GO - Now right-click in that code space and select “Execute”. If you experience this error: “Execution of user code in the .NET Framework is disabled. Enable “clr enabled” configuration option”, then execute the following query first:
sp_configure ‘clr enabled’, 1
go
reconfigure
go - You should see the text “Hello!” appearing in your output window
- To do something that’s actually useful, we can add in the following code to our stored procedure, which essentially selects all records in our database and outputs them:
SqlConnection conn = new SqlConnection(”Context Connection=true”);
SqlCommand cmd = new SqlCommand(@”SELECT * FROM YourTable”, conn);conn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
SqlContext.Pipe.Send(rdr);rdr.Close();
conn.Close(); - Done! You have just created and run your first stored procedure. Wasn’t that easy?
Subscribe to my blog:
RSS reader
Email
What Does Blue Square Icon or Blue E Icon on iPhone Mean?
The iPhone uses a pretty simplified and minimalistic interface which is great 99% of the time, but occasionally it does show some icons that come without labels which I don’t understand.
For instance, I was trying to figure out what a solid blue square in the iPhone’s status bar meant. And sometimes it appears as a capital “E. Well, it turns out that the “E” means that the iPhone is connected to the EDGE network.
The solid blue square indicates that the iPhone can’t find a nearby EDGE network, and is instead connecting via standard GPRS. Generally, GPRS offer slower data transfer rates relative to an EDGE connection. Funny thing is, I seem to get these icons appearing when I’m 100% sure that I’m not connected to EDGE or GPRS.
Subscribe to my blog:
RSS reader
Email
Can’t Call Out With The iPhone? Fix To The Call Failed Problem with iPhone
I found out that my new iPhone has terrible reception, even in places with supposedly good coverage. It turns out that it’s because of certain settings that I didn’t configure properly. After I changed them, all was good again!
So if your iPhone is like mine and you see “Call Ended” and then “Call Failed” immediately after trying to dial out from your iPhone, even though there’s a good signal (i.e. you can see signal bars, so you are connected to your carrier). Then relax, because there probably is no problem with the phone — you PROBABLY just need to do these 2 steps:
1) Go to Settings > General > Date and Time. Switch off “Set Automatically” and manually select your hometown (the default is Cupertino). If you dont change it, you will not be able to make outgoing calls. But the wierd part is, you will still be able to receive incoming calls. Once done, manually set the date and time, and restart your iPhone. If you want, you can reset the 2 settings to “Set Automatically” again.
2) Next, go to Settings > Phone > Show My Caller ID > Switch this to “ON”. Usually with these steps, things should be okay already. If not, you have to turn off “Call Forwarding” and “Call Waiting” as well.
Hope that helps!
Subscribe to my blog:
RSS reader
Email
Cheap iPhone Earphones From eBay - The Real Deal?
One of the problems with my previous phone - the Samsung i780 - was that it was incredibly hard to find accessories for it. I couldn’t find a headphone jack converter for it - and I really needed it because I couldn’t use the stock earphones as they kept falling out. So I couldn’t use my normal earphones with it, which was a bummer.
With the iPhone, it came with an in-built 3.5mm headphone jack, so things were great - or so I thought. Turns out that the iPhone’s headphone jack was 3.5mm, but it was recessed so that only mini 3.5mm plugs could fit it. That meant that I couldn’t use my Panasonic earphones with it (the earphones had a L-shaped jack).
Since it was about time that I changed earphones, I went to look around for a good pair, and I found that the Creative EP-630’s came well recommended for their value for money. The first place that I tried to get a pair at was eBay, and imagine my surprise when I found that the earphones were sold at nearly half-price! Thinking that it was extremely lucky of me to have found this super-bargain, I nearly purchased them on the spot, but for some reason, I didn’t — good thing though! I poked around, and found some places discussing the earphones that were listed on eBay and other places that were a fraction of the original retail prices. It turns out that almost all of these earphones were imitations and sounded nowhere close to their originals.
They look almost identical though - and they had imitations for almost any models in the market. For the plain Apple earphones to the complex Shures — everything was online and for sale. And just by the pictures on the listings, it was almost impossible to tell the real from the fake. The fakes even came with packaging so real you’d be amazed! After looking through several listings, I realised that there are some cases that have obvious mistakes though - just take a look at the listing photo below of these Panasonic RP-HJE500 earphones that supposedly came with aluminium housings, or in this case, “alminium housing”.

After receiving the earphones, you’ll realise that they’re manufactured at a lower quality too. For example, if you were to get a pair of Shures, you might realise that the imitations have plastic grey capsules, unlike the more metallic texture of the originals. The top halves might also be made of glossy plastic instead of the matte finish in the originals. The letters in the Shure logo are placed further apart from each other and in some cases, the “R” and “E” characters don’t connect like in the case of the authentic Shure logo.
So if you’re buying from eBay and the seller/price looks too good to be true - then it probably is! The earphones are probably still fine if you’re not too discerning about sound quality though - they aren’t the originals, but at those prices, they can be your pair of backup earphones or earphones for more rough use, like when you go exercising.

In the end, I decided to go to Amazon instead, and purchased my pair of Creative EP-630’s (link to Creative EP-630). It comes with a straight plug, and the sound quality is awesome for its price!
Subscribe to my blog:
RSS reader
Email
Samsung i780 versus Apple iPhone
To cut a long story short, I sold off my Samsung i780 for an Apple iPhone. I bought the Samsung i780 at SGD680, and sold it off for SGD480. It was 3 months old, but in great condition, and I hated to see it go.
So that’s a SGD200 loss. Verdict? I love the iPhone. It’s gorgeous and user-friendly as hell. After getting it, I realised how clunky the Windows Mobile interface was. It just isn’t intuitive as the iPhone’s, or even Palm’s (which was what I was using before I switched to my Samsung i780).

With the switch, I gave up certain features like the ability to edit Office documents, do custom Windows Mobile programming, and use Microsoft Exchange, but I realised that it wasn’t a big deal at all. In fact, I didn’t even miss those features. So I guess it really boils down to what you really need, versus every features thrown into the mix. The Windows Mobile interface just didn’t cut it for me, which was why I decided to sell the i780, and I’m glad I did so!
Updates about the iPhone soon!
Subscribe to my blog:
RSS reader
Email
24 Jul 08 | 

