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"