Wednesday, December 24, 2008

I use Wikipedia.

I use it a lot. Like today, for example, when I was curious about how the double-switch works, in baseball.

So after I read the article which Explained It All For Me, I clicked the link in the header and read the plea for donations. And I donated.

I don't donate often, even for good causes, but Wikipedia has made my life easier, and I'm grateful.
Wikipedia Affiliate Button

Saturday, December 20, 2008

Open in New Window Size

It can drive me crazy, how sometimes you choose the option to open a link in a new window, in Internet Explorer, and the new window isn't the size you want.

I was dealing with that just a few minutes ago, because I had a list of links open in one window, and I was one-by-one right-clicking them and choosing Open in New Window.

Here's how I solve the problem. (I still have Internet Explorer 6.)

1. If the source window is maximized, restore it to its sizable state. You can do this by double-clicking the title bar, for example.

2. Now, make this window be the size you that want new windows to be. Position it where you want new windows to be positioned.

3. Maximize the window. Restore it again, and notice how the size and position are as you left them. Re-maximize it.

4. Now, right-click a link and choose Open in New Window. It opens in the position that you set, and in the size that you set.

Friday, December 19, 2008

Where is the SQL Express install log?

The SQL Express installer (unlike MSDE) produces a log file by default. There is no need to specify extra parameters when running setup.exe.

The log gets written to:

%ProgramFiles%\Microsoft SQL Server\90\Setup Bootstrap\LOG\Summary.txt

For example, on my machine,

C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Summary.txt

Multiple other log files are written to the same folder, because the SQL Express install actually comprises multiple other installs.

Thursday, December 18, 2008

Where is the MSDE install log?

Where you can find the MSDE install log depends on what options you chose when you ran your install.

By default, no log is produced when you run setup.exe to install MSDE. To get a log, you have to add the /L parameter.

To get the MSDE install to log:

1. In the MSDE installer folder, right-click Setup.exe and create a shortcut

2. View properties for the shortcut, and at the end of the Target string, add

/L*v C:\MSDE_setup.log

For example:

"C:\MSDE\setup.exe" /L*v C:\MSDE_setup.log

3. Install by running the shortcut.

Note that /L tells setup to produce a log. The *v parameter makes it a verbose log. And C:\MSDE_setup.log is the location of the log that will be produced.

You can use a different location and/or filename. Setup will overwrite the file if it already exists.

Saturday, December 6, 2008

The Microsoft Jet database engine could not find the object filename.

I got this error trying to open DBF files using Access: The Microsoft Jet database engine could not find the object filename. Make sure the object exists and that you spell its name and the path name correctly.

I had a folder full of dBASE IV DBF files. Turns out the problem was that my file names were longer than 8 characters.

For example, after I renamed "My Customers.DBF" to "CUST.DBF", it opened just fine.

I had a lot of files I had to rename, which sucked.

Friday, December 5, 2008

Password for the NETWORK SERVICE account

The NETWORK SERVICE account does not have a password. When you're configuring a service to run using this account, you can blank out the password fields, or enter anything and it will be ignored.

What you CAN'T do is leave the original placeholder dots. If you do, it'll keep telling you to enter a valid password.

In the past, in order to document necessary permissions for files and databases, I have had to test running the same service using the local SYSTEM account, the NETWORK SERVICE account, and a local or domain account.

To change to SYSTEM, you just select the radio button. But when it's time to switch back to NETWORK SERVICE, it's confusing. It is not obvious, what you should enter for a password.

If you explicitly blank out the password fields, you'll be good.

Friday, November 28, 2008

How to find the IUSR password and IWAM password in IIS

If you allow anonymous users to access your Web site, they'll be accessing your computer using the built-in IUSR_computername account that is created automatically by IIS.

Processes initiated by IIS run on your machine using the built-in IWAM_computername account, also created automatically by IIS.

This is all configurable -- you can configure IIS to use other accounts for anonymous access, and for processes. But by default, these are the ones that get used.

Here is how to find out the passwords for the IUSR or IWAM accounts:

1. Navigate to C:\Inetpub\AdminScripts

2. Edit the file called adsutil.vbs

3. Scroll down almost to the bottom, to where it says

If (Attribute = True) Then

IsSecureProperty = True

Else

IsSecureProperty = False

End If

4. On the first condition, change True to False, like this



5. Save the change.

6. Now that you have modified the script, you can run a couple of commands to discover the IUSR and IWAM passwords. Open a command window. To see the IUSR password, run this command:

cscript.exe c:\inetpub\adminscripts\adsutil.vbs get w3svc/wamuserpass

To see the IWAM password, run this command:

cscript.exe c:\inetpub\adminscripts\adsutil.vbs get w3svc/anonymoususerpass

The output will be in double quotes. The double quotes are not part of the password.

7. Once you've retrieved your passwords, edit adsutil.vbs again and change False back to True. You don't want someone with malicious intent to learn these passwords.

Monday, November 24, 2008

Where are LogFiles for IIS 7?

Last Thursday I was dealing with a web app that wouldn't work on a computer running Vista. I needed to check the IIS log file, so I went where I always go -- to

C:\Windows\System32\LogFiles. But there was no LogFiles folder. There was HTTPERR, and some unfamiliar folders, but no LogFiles.

Turns out that for IIS7, log files don't live there any more. They have moved to C:\Inetpub\LogFiles.

I didn't check my 2008 Server, but I suppose that will be true for IIS version 7 there, also.

Sunday, November 23, 2008

How to save YouTube videos

A real person asked, "How do I download clips from YouTube to my computer?"

There are sites where you can paste in the URL from YouTube, and then download the file. I use this one:

http://www.videodownloadx.com/

Steps:

1. In the download field, paste the full URL from YouTube. For example, http://www.youtube.com/watch?v=abrKM1Z_te8

2. Click the Download Video button.

3. Notice the screen re-displays. Scroll down a bit if necessary, and on the left beside the Ads by Yahoo you will see a small image of your video. In between the ads there's some text that looks like this:

>> Download Convert Record Stream<<

4. In this text, click on the word Download.

5. When prompted, choose to save the file.

6. In the Save As dialog (or equivalent if you're not on Windows or not using Internet Explorer), replace all the text in the File Name field with a meaningful file name that has .flv as the file type. For example, Californication.flv.

7. Click Save (or equivalent) to save the file.

Thing is, the file you download will be a .flv file, and you will need a special player to play it. I use the one that comes up when you google the term "flv player". It's a link to freeware downloadable from CNET's download site. Right now, that link is

http://www.download.com/FLV-Player/3000-13632_4-10896762.html

Download and install that player, which is free, and you will be able to play the FLV files you download.

Hope this helps!

Saturday, November 22, 2008

The procedure entry point ?SQLUIUpdateRegistryFromResource@@YAJHPAUHINSTANCE__@@IKPAPBG1@Z could not be located in the dynamic link library SQLRESLD.dll.

Had a customer the other day who was installing an app on Windows 2000 Professional. We don't see Windows 2000 much any more, even 2000 Server. Anyway, this particular machine had been around for years, and had a lot of old apps installed on it, including Microsoft SQL Server version 7.

Whenever the customer would launch our app, he'd get this error:

The procedure entry point ?SQLUIUpdateRegistryFromResource@@YAJHPAUHINSTANCE__@@IKPAPBG1@Z could not be located in the dynamic link library SQLRESLD.dll.

Then he'd click OK, and he'd get this error:

System.Runtime.InteropServices.COMException (0x8007007F): Retrieving the COM class factory for component with CLSID {10020200-E260-11CF-AE68-00AA004A34D5} FAILED DUE TO THE FOLLOWING ERROR: 8007007F.

This second error was recognizable - that's the class ID for SQL-DMO, which the app uses to communicate with SQL Server. We see that 0x8007007F error for that class ID all the time, on machines where SQL-DMO is not registered.

The usual solution is to go find SQLDMO.DLL in C:\Program Files\Microsoft SQL Server\80\Tools\Binn, and register it using regsvr32.exe. Or, sometimes we throw a copy of SQLDMO.DLL and SQLDMO.RLL in our own app folder, and register it there, just to get by.

(A quick note about registering DLLs: you can bring up a command window and navigate to the folder where the DLL resides, and then run regsvr32.exe sqldmo.dll, for example. But most of the time, I right-click on the DLL and choose Open With, and browse to regsvr32.exe in C:\Windows\System32, and make a permanent file type association. That way, from then on I can register any DLL just by double-clicking it. If I get an error that the DllRegisterServer entry point can't be found, then I know it didn't need registering in the first place.)

Back to the IKPAPBG1 issue. we tried to register SQL-DMO, and that failed. I don't have the error handy, but the gist of it was that some RLL couldn't be found at C:\Resources\1033. For this, we tried brute force, and copied

C:\Program Files\Microsoft SQL Server\MSSQL$INSTANCENAME\Binn\Resources\1033

to

C:\Resources\1033.

Not the "right" solution, but worth trying to see if it would get us up and running.

Tried to register SQLDMO.DLL again, and this time, the error thrown by regsvr32 was

C:\Program Files\Microsoft SQL Server\MSSQL$INSTANCENAME\Binn\sqlresld.dll
was loaded, but the DllUnregisterServer entry point was not found.

DllUnregisterserver may not be exported, or a corrupt version of C:\Program Files\Microsoft SQL Server\MSSQL$HDBID\Binn\sqlresld.dll may be in memory. Consider using PView to detect and remove it.

By this time, all the errors together were beginning point to a versioning problem. As if, for some reason, version 7 DLLs were being accessed instead of version 8 (2000). What would make that happen?

In Add/Remove programs, we could see that MSSQL 7 was still installed, although it wasn't running. We checked the Path environment variable, and noticed that C:\MSSQL7 was near the front of the list.

We considered removing it from the Path, since it wasn't in use, but decided instead to try renaming the C:\MSSQL7 folder so it wouldn't interfere. And that did the trick. We ran regsvr32.exe sqldmo.dll, and it worked, and we launched the app, and it worked too.

Solved. If this story helps you, post a comment and let me know!

Thursday, November 20, 2008

Unable to open the physical file "C:\MyDatabase.mdf". Operating system error 5: "5(Access is denied.)"

One of the applications I test frequently detaches and re-attaches SQL Server databases. The app manages hundreds of databases all with identical schema, detachable for portability and ease of copying.

Originally the app only worked with SQL Server 2000 (or MSDE), but after SQL Server 2005 (SQL Express) had been available for a while, we decided to support it too. It turned out to be harder than we expected, because every time we detached a database, we were unable to attach it later.

The errors looked like this:

Unable to open the physical file "C:\MyDatabase.mdf". Operating system error 5: "5(Access is denied.)"

Turns out that SQL Server 2005, in order to better secure the data inside an MDF file, automatically resets file permissions whenever the MDF is detached. I got no problem with that -- it makes sense, when you think about how before, your data was always securable as long as you were accessing it through the SQL Server engine, but if you forgot to secure your MDFs and LDFs, anyone who got their hands on those could probably get whatever information they wanted out of them.

Just, for our app, it made life crazy. Permissions would get reset so that only the person who did the detach could re-attach. Or sometimes, a process running as a service under the Local System account would detach, and then nobody could manually re-attach.

Luckily, after a lot of research that took way too long, we discovered trace flag 1802. Trace flag 1802 turns off the permission-resetting behavior. This particular trace flag needs to be set in the startup properties for the instance, so that it is always in effect. If you set it dynamically using DBCC TRACEON, it won't stick through the next time you restart your instance.

To enable trace flag 1802:
1. Start > Programs > Microsoft SQL Server 2005 > Configuration Tools > SQL Server Configuration Manager

2. In the tree list on the left, click on SQL Server 2005 Services

3. On the right, right-click your SQL Server instance name, and choose Properties

4. In the Properties dialog, click on the Advanced tab

5. Find the property called Startup Parameters. There is a long string of parameters in this field. Click the dropdown arrow to view and edit the string.

6. At the end of the string, add ;-T1802



Friday, September 5, 2008

Cannot copy (filename): The filename, directory name, or volume label syntax is incorrect.

One of the products I test is available for download, in addition to being available on CD media. We use WinZip to create a single-file self-extracting downloadable version. Our customers are able to download a ProdName.exe file, and run it to extract the CD image to a local or network folder.

Sometimes, depending on where they extract it to, they get an error. The problem is that our product CD incorporates the SQL Express installer, which has a very deep folder structure of its own. The longest path in the product CD folder structure is 186 characters:

\Bin\3rdParty\SQLExpress\setup\program files\microsoft sql server\90\tools\binn \windows\winsxs\3kn09qps.lm8\x86_microsoft.vc80.mfcloc_1fc8b3b9a1e18e3b_ 8.0.50727.42_x-ww_3415f6d0.manifest

If someone attempts to extract the contents to a directory that has a long path already, they can get this error:

Cannot copy (filename): The filename, directory name, or volume label syntax is incorrect.

Or, if they're able to extract it successfully, sometimes they get this error when they try to copy the entire CD directory to a different location:

Can't create output file: (filename)

The errors occur because the maximum length of a Windows path is 260 characters.

The solution is to extract or copy the install to a folder with a shorter path name. In our case, because our sub-path takes up 186 characters, everything that comes before \Bin... must have a length not more than 74 characters.

Tuesday, September 2, 2008

How do you know what version of SQL Server you have?

To find out what version and service pack of SQL Server you are running, run this query:

SELECT @@VERSION

For example, I'm at home right now using an old laptop running Windows XP Home, and in the Services console I see only one SQL Server 2000 instance called MICROSOFTBCM.

I've never used BCM, but I know it stands for Business Contact Manager and it is part of Microsoft Office. Let's see what version of SQL Server it is, and what service pack is installed.

First, I open a command window and type:

c:> osql -S localhost\microsoftbcm -E

The response is:

[DBNETLIB]SQL Server does not exist or access denied.
[DBNETLIB]ConnectionOpen (Connect()).

I can see in the Services console that the MSSQL$MICROSOFTBCM service is Started, so I figure maybe TCP/IP connections are not enabled. In the command window, I type:

c:> svrnetcn

This brings up the SQL Server Network Utility. Sure enough, TCP/IP is in the list of Disabled Protocols. So I select it, click the Enable button, and click Apply. An alert tells me I need to restart the service in order for the change to take effect, so I switch over to the Services console and restart the service.

Now I try OSQL again, and this time I get connected. I type:

1> select @@version
2> go

The response is:

Microsoft SQL Server 2000 - 8.00.818 (Intel X86)
May 31 2003 16:08:15
Copyright (c) 1988-2003 Microsoft Corporation
Desktop Engine on Windows NT 5.1 (Build 2600: Service Pack 2)

So now I can tell I'm running MSDE with SP2.

I think I'll disable TCP/IP again, since I don't really need it. I don't use this app. In fact, I'm going to disable the service so it won't start any more when I reboot.

Thursday, August 28, 2008

Batch file to back up a folder and add a timestamp

Last week I needed to write a batch file to copy a directory to another location, but back up the existing target directory first, if it already existed.

I needed a unique name for the backup copy, so that the command could be run repeatedly.

Here it is. Notice the /s and /e parameters on the xcopy command. That's to include the subfolders, including the empty ones:

@echo off
ECHO *********************************************
ECHO * This command will:
ECHO *
ECHO * 1. rename the existing MyFolder directory
ECHO *
ECHO * 2. replace it with a fresh MyFolder.
ECHO *
ECHO *
ECHO * Press Ctrl + C to cancel execution.
ECHO *
ECHO **********************************************

PAUSE

set FileDate=%date:~10,4%_%date:~4,2%_%date:~7,2%
set FileTime=%time:~,2%%time:~3,2%%time:~6,2%%time:~9,2%

rename "C:\Target\MyFolder\" "MyFolder %FileDate% %FileTime%"

xcopy "C:\Source\MyFolder\*.*" /s /e "C:\Target\MyFolder\"

Wednesday, August 27, 2008

Enterprise Manager snap-in failed

Once upon a time, there were days when I'd swear I installed & uninstalled MSDE fifty times. And sometimes I would discover, next time I tried to use SQL 2000 Enterprise Manager, that it wouldn't work any more. I'd get this error:

Enterprise Manager snap-in failed

When this happens, the quickest solution is to re-install Client Tools. If the SQL Server 2000 installer is handy, grab it and run a Client Tools Only install.

But often, that doesn't run smoothly. I get this error:

Setup has detected an existing client tools only installation. Please use the maintenance mode to add client components

To get past this, edit the registry.

1. Run regedit.

2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\80\Tools

3. Change the value of DefClientOnlyInstalled to 0.

4. Re-install Client Tools. It should work, and it will probably set the value back to 1.

Now you can use Enterprise Manager again.

I have also read of another solution, that doesn't involve installing Client Tools again. This is useful if you don't have a SQL Server 2000 CD handy, or don't have access to an installer locally or on a network drive.

1. Run Regedit.

2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\80\Tools\ClientSetup

3. On the right side, right-click and choose New-->String Value.

4. Name the new value SQLPath.

5. Double-click the SQLPath value to edit it. In the Value data field, enter:

C:\Program Files\Microsoft SQL Server\80\Tools

6. Click OK, then close Regedit.

7. At a command prompt, run:

regsvr32 "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlmmc.dll"

I haven't had a chance to try this since I learned it, because it's been a while since I got a Snap-in failed to initialize error. If you try and it works for you, please let me know. Thanks.

Tuesday, August 26, 2008

ODBC--call failed. [Microsoft][ODBC SQL Server Driver]Timeout expired (#0)

In Microsoft Access, when you open a pass-through query to a SQL Server 2000 or SQL Server 2005 database, sometimes the query times out. Usually for me this happens when the database is very large.

The error message is:

ODBC--call failed. [Microsoft][ODBC SQL Server Driver]Timeout expired (#0)

You can set the timeout interval for ODBC connections in the registry. It is a setting for the Microsoft JET 4.0 engine, which is the database engine that Access 2003 uses.

(When you create a new ODBC DSN, and see all those drivers listed that are version 4.00 and contained in ODBCJT32.DLL -- those drivers are part of JET and likely came with MDAC.)

The QueryTimeout value lives in the registry at

HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\ODBC

The default value is 60 seconds. You can increase the timeout setting, or change it to 0 so that queries will never time out.

Follow these steps:

1. Close Access.

2. Start --> Run

3. In the Open field, type regedit and click OK to run the Registry Editor.

4. Expand HKEY_LOCAL_MACHINE. Expand Software. Expand Microsoft.
Continue navigating to Jet\4.0\Engines\ODBC folder.


5. On the right side, double-click the QueryTimeout value to edit it.

6. Under Base, click the Decimal radio button.

7. In the Value data field, enter a new number of seconds. Or, enter 0 to allow unlimited time.


8. Click OK. Exit Registry Editor.

Now you can restart Access and try the query again.

Monday, August 25, 2008

What are the different versions of IIS?

A couple of weeks ago, He Who Is Colorful needed to document technical requirements for a new product. I got an IM from him asking what versions of IIS would be our "supported configurations."

Well, I don't think in terms of versions of IIS; I think in terms of operating systems. I know the app works on XP and 2003 Server, and I know I'm not going to bother testing 2000 until some customer needs it.

I bet I could make it work on Vista, but I'm not going to bother testing that either because I know our installer currently won't create virtual directories on Vista unless IIS is installed with Backwards Compatibility -- because of the new way IIS metabase information is stored. And besides, we're not going to support XP or Vista anyway, because they're not server operating systems, and won't support a realistic number of users hitting IIS at once. Not sure what you get with Vista, but with XP you only get 10 connections.

As for 2008 Server, it'll have the same limitation with our installer as Vista has.

Too late for a long story to be short, but anyway, I had to look up IIS version numbers for each OS. Don't want to have to do it again, so I'm documenting it here:

Windows 2000 Server: IIS 5.0
Windows XP: IIS 5.1
Windows 2003 Server: IIS 6.0
Windows Vista: IIS 7.0
Windows 2008 Server: IIS 7.0 also

Reference: Wikipedia

Thursday, August 14, 2008

How to run all SQL scripts in a folder

Suppose you have a set of SQL scripts for SQL Server that you want to run regularly. Place them all in a single folder, and then you can run a single command file to execute them all.

Here is an example:

for %z in (c:\Scripts\*.sql) do osql -S computername\instancename -U username -P password -d databasename -n -b -i %z

You can also do the same thing, except connect to the SQL Server using Windows Authentication instead of a SQL Server login using the -E parameter instead of -U and -P:

for %z in (c:\Scripts\*.sql) do osql -S computername\instancename -E -d databasename -n -b -i %z

Those dashed parameters (-S, -U, -P, -E, -d, -n, -b, -i) are for OSQL. Case matters. For example, -d is not the same as -D.

You can see all the possible OSQL parameters by running the command OSQL ?. For quick reference, here's a screenshot of what's returned when you run OSQL ?:


Wednesday, August 13, 2008

How do you know what version of Windows you have?

You can find out what version of Windows you have, including what service pack (for example, XP vs. XP SP2) by running the winver command.

1. Click the Start button, then click the Run menu option.

2. In the Open field, type winver and click OK.


Tuesday, August 12, 2008

Couldn't get process information from remote machine

Sometimes our customers install one of our end-user apps on Terminal Server, or Citrix. In these environments, individual users are not typically machine administrators.

There's functionality in our app that requires it to launch some external third-party applications, which we then integrate with -- syncing data back and forth.

Before our app launches the other program, it needs to know if that other program is already running. It looks for an already-running process with the other app's name.

Problem is, on Windows 2003 Server, standard users don't have the authority to look at other processes. We see an error:

Couldn't get process information from remote machine

When this happens, we advise our customer's IT department to add their end users to the Performance Monitor Users Group. This gives them the right to query running processes, without giving them the unwanted rights that making them machine administrators would.