Thursday, December 18, 2008

javascript focus doesn't work

Had this issue working with .net and javascript. I had the issue where I was trying to set focus on a text box. But, for some reason, I couldn't set focus. I could set focus on drop down boxes in the same window.

Solution, instead of using .focus, I used .select. I still haven't figure out the reasoning behind it, but select worked, focus did not.

Monday, March 17, 2008

How do I have a select distinct and a top x in the same query

Ah, this one puzzled me. I had to go to the internet, and I still didn't quite get it. But, here is the solution.

SELECT
distinct top 3 y.*
FROM
(Select topicid, max(posted) as posted from yaf_Message Group by topicid) y

Order By Posted DESC

How does it work?
Ok, the initial select defines the top values returned.
The From creates another table with only those values that I need. So, when the first select looks in the table, it is looking in a filtered table.

Thursday, March 13, 2008

How to access masterpage values from a page

Ok, had this issue. The site allows you to log in and set some preferences. One of these preferences changes the links in the top navigation. So, when it was being set in the preferences page, it wasn't updating the top navigation.

Here's some background as to why. When the preferences were set in the sub page, it would load up the master page first, then set the value. That is the first issue. So, how do I update the master page after the fact. Well, after some quick discovery, I found this article. It saved me. Took 5 minutes after I read this article.

http://www.thescripts.com/forum/thread343203.html

Wednesday, March 12, 2008

What is my mail server's IP address?

Every once in a while, I'll send an email to a client of mine with Yahoo email and I receive an error message. The error message is below. What I found out is that I have to report it to Yahoo and they may clear me. Not sure how long this will take or even if it will work, so I'll find out soon enough.

So, to file the complaint, I was sent to this Yahoo address for 421 errors: http://help.yahoo.com/help/us/mail/defer/defer-06.html

Once there, I filled out some information, mostly about the email. But, one thing hung me up for a little while. How to get my mail server's IP address. It only took a minute, so here's how to get your mail server's IP address.

1. In Windows, click on Start | run
2. Type in the text cmd then click on the OK button.
3. You should now see a small black window with white text.
4. In that box, type in ping mail.yourdomainname.com (fill in yourdomainname.com with your domain name)
5. Hit enter
6. If this works, you will see the IP address of your mail server.
7. To close the window, type in the words exit, then hit enter.



Here's the error message:
Could not deliver message to the following recipient(s):

Failed Recipient: xyz@yahoo.com
Reason: Remote host said: 421 Message from (xyz) temporarily deferred - 4.16.50. Please refer to http://help.yahoo.com/help/us/mail/defer/defer-06.html

-- The header and top 20 lines of the message follows --

Received: from IMAIL2 [1.1.1.1] by x.x.x with SMTP;
Wed, 12 Mar 2008 07:21:52 -0500
Received: from syx [1.1.1.1] by x.x.x with ESMTP
(SMTPD-8.22) id AB9C0D58; Wed, 12 Mar 2008 06:16:44 -0500
From: "person a"
To: "'person b'"
References: <010401c8839a$1f5b2b90$5e1182b0$@bailey@bluecreekweb.com> <551043.95195.qm@web53004.mail.re2.yahoo.com>
In-Reply-To: <551043.95195.qm@web53004.mail.re2.yahoo.com>
Subject: RE: New Order
Date: Wed, 12 Mar 2008 07:16:43 -0400
Message-ID: <000001c88432$8dfe1790$a9fa46b0$@bailey@bluecreekweb.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0001_01C88411.06EC7790"
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: AciDoLveNFKaJDfJSpGamAweiCoPMgAkcCdg
Content-Language: en-us
X-Declude-Sender: joe.bailey@bluecreekweb.com [97.80.142.6]
X-Declude-Spoolname: Dbb9c02210000d12b.smd
X-Declude-RefID:
X-Note: Outgoing Scanned by IMail.GlobalWeb.net 4.3.64
X-Scan: Score [0] at 06:16:52 on 12 Mar 2008
X-Fail: Whitelisted
X-Country-Chain:

This is a multipart message in MIME format.

Wednesday, March 5, 2008

An error has occurred while establishing a connection to the server.

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I've seen this one before but it seems like the reasoning is different every time. This time, the error showed up because the computer was restarted. Since SQL Express was running before, I assumed that something wasn't started, and that was correct. To fix the problem, I had to start SQL Server (SQLEXPRESS) in the Services. Then, I changed the properties so it wouldn't happen again. Here's how I did it.

1. Go to Start | Control Panel
2. Double click on Administrative Tools
3. Double click on Services
4. Sort the services by name, this just makes it easier.
5. Find SQL Server (SQLEXPRESS). Look to see if the status is started or not. Hopefully, it isn't so this will fix the issue.
6. Highlight SQL Server (SQLEXPRESS), right click on it and choose Start. This will start it up.
7. Test it to make sure everything works by trying to connect to the database with Microsoft SQL Server Management Studio.
8. If this didn't fix it, something else may be wrong.
9. Now, to prevent this from happening again, right click on SQL Server (SQLEXPRESS) again and choose properties.
10. In the startup type drop down box, choose "Automatic"

Thursday, February 28, 2008

CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

How did I get this? I forgot to put the () at the end of a response.end while in c#. I'm slipping every once in a while. At the current time, I'm switching back and forth between VB.NET, C#, classic ASP and Cold Fusion. Sometimes, I forget where I am :)

Tuesday, January 22, 2008

How to create a machinekey for your web.config

Issue: I'm trying to make the session persistent across two applications. The key is to set the machinekey in the web.config under .

I didn't know how to figure out or create my machinekey without getting involved in more code. I figured there had to be a quick way, a way that wouldn't put me on a tangent. Then, I found it.

Go here to produce your own .net 1.1 and .net 2 keys
http://www.developmentnow.com/articles/machinekey_generator.aspx

Wednesday, January 16, 2008

C# SQL2005 money and displaying it

Quick note:

I'm retrieving a money value from a sql server 2005 database. When walking through the reader, I want to display the dollar amount formatted correctly. But, it keeps coming up incorrect. For example: 200.00000 instead of $200.00.

Solution:
I was looping through the reader, converting the value to a string then trying to format it. I took out the .toString() and it worked fine.

correct usage:
String.Format("{0:c}",reader["dollarvalue"])

Also, if we are prefilling a text box, we do not want to show the $ sign. So, we use a different format:
String.Format("{0:f}", reader["dollarvalue"])

Monday, January 7, 2008

Issues starting IIS

This morning, I restarted my computer, tried to browse to a local site for programming and it wouldn't start. Went to IIS to check it out, I noticed it wasn't started and had a red stop sign on the directory of sites. I tried to start it and this is the message I saw:

unexpected error 0x8ffe2740 occurred

Nice, well, I checked the MS online docs and it told me I had another application using the same port. I downloaded tcpView to see which application it could be. TCPView couldn't tell me initially what it could be based on ports. It turned out, that if i stopped Skype, I could restart IIS.

So, resolution, start IIS before Skype, and/or change port settings for Skyp.