Search This Blog

Monday, August 1, 2016

Monday, April 25, 2016

Just more ammo...

Not programming related, but useful to know... Recently, our PC's at my work has been randomly giving the error “User profile service failed the logon. User profile cannot loaded” message. If a user had logged onto the machine prior, they could log on, but if the person had not logged on before, they may or may not be able to log in. The below steps will resolve the issue.

  1. Run Windows Explorer with Administrative Rights (You may have to login as the local admin.)
  2. Browse to C:\Users
  3. Tap ALT, then Tools, then Folder Options.
  4. Select the View Tab
  5. Select Show hidden files, folders, or drives
  6. Click Ok.
  7. You should now see Default in the list of users.
  8. Right Click on the Default, select Properties.
  9. Click on Security
  10. Click on Advanced
  11. Click on Change Permissions
  12. Check the 'Replace all child object permissions with inheritable permissions from this object
  13. Click OK all the way out.
  14. It will prompt you to change permissions, click OK (or Yes).
  15. Log out and users should now be able to log in.



#14 above may be different, but that’s what my recollection of it is. 

Monday, August 19, 2013

Something useful for myself

Replacing a string in MS SQL.

REPLACE(OriginalField, "OldString", "NewString")

SELECT REPLACE(LastName, "Smith", "OriginalSmith")

This would change all occurrences of Smith in the LastName field to OriginalSmith. Smith becomes OriginalSmith, O'Smith becomes O'OriginalSmith, smithey becomes OriginalSmithey, and so forth. Microsoft has this on their site, but sometimes their terminology is too technical when looking for a quick answer.

Wednesday, August 7, 2013

Cursors in MS SQL

I'm always forgetting now to do a simple cursor in MS SQL, so here is the basic structure

DECLARE @field1 VARCHAR(10)
DECLARE @field2 VARCHAR(10)

DECLARE name_cursor CURSOR
FOR
SELECT field1, field2 FROM table WHERE this = 'that'

OPEN name_cursor

FETCH NEXT FROM name_cursor INTO @field1, @field2

WHILE @@FETCH_STATUS = 0
BEGIN
--DO WORK HERE
FETCH NEXT FROM name_cursor INTO @field1, @field2
END

CLOSE name_cursor
DEALLOCATE name_cursor

An alternate would be
WHILE @@FETCH_STATUS <> -1 -- -1 indicates beyond result set
BEGIN
IF @@FETCH_STATUS <> -2 -- -2 indicates row is missing
BEGIN
--DO WORK
FETCH NEXT
END
END

Tuesday, July 13, 2010

Effective Way to Remove CR LF in MySQL Query

I had a need to replace new lines in a query that was causing issues elsewhere in a process flow that I was working on. While removing the new lines in code would be easy, the problem was that they were needed to designate the end of a line in a file. So, I decided to remove them at the earliest possible step, and that is at the query. So, to do so, here is the statement...

REPLACE(REPLACE(userEnteredField, CHAR(10), ''), CHAR(13), '')

Since we are not sure if the input is inputing the new line as Carriage Return, Line Feed, or both, you first replace one, then replace the other. Most solutions I see posted have REPLACE(userEnteredField, CHAR(10) + CHAR(13)) which works if they are both present. The way done replaces, one or the other or both.

Thursday, May 6, 2010

I'm always searching for this...

To get the datakey on rowdatabound event for gridviews.


if (e.Row.RowType == DataControlRowType.DataRow)
{
string strY = GridView2.DataKeys[e.Row.RowIndex].Values[1].ToString();
}

The number 1 could be replaced with "KeyName" also.

Sunday, January 31, 2010

Getting Buffalo NFiniti wireless adapter working in linux

Recently, in getting the home dvr setup and working, it needed to be moved into another room. The best solution would be to run cat5 cable to that room, but to do it properly was going to be cumbersome, getting into the attic and running wires is not fun. The easy solution was to get wireless setup on the pc.

I searched and found a reasonably priced wireless-n card on Amazon. It was a Buffalo NFinity Wireless-N USB 2.0 adapter. This will hopefully give me the needed speed when viewing HD content on my PS3 in another room.

Well, the product arrives, and the process of getting installed under Linux began. Unfortunately it did not work "out of the box" so I started searching for what the card really was.... and in the end, it turns out to be a Ralink chipset card, and uses the RT3070USB drivers. They are downloadable from their website. This was like 3 or 4 hour search.

But the fun did not end there. Come to find out, the card may or may not have its "id" in the files provided from Ralink, so I had to modify the source to get it to work. Finally, after that, it worked like a charm.

Here are the steps I took to get this card working in Myth/Ubuntu 9.10...

1. Obtain drivers from Ralink (Ralink Driver Site).
2. Download the RT3070USB(RT307x) driver. In my case it was 2009_1110_RT3070_Linux_STA_v2.1.2.0.tar.bz2
3. Uncompress the resulting file with tar -xvzf 2009_1110_RT3070_Linux_STA_v2.1.2.0.tar (change as needed for the most current driver)
4. CD to the directory created
5. CD to the os/linux directory
6. Open the config.mk file in your favorite editor
7. In the config.mx file, change the HAS_WPA_SUPPLICANT=n and the HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n lines to have =y on the end instead of =n.
8. Save the file.
9. In a terminal window, type in lsusb. You should get a line that ends in Melco, Inc.
10. Notate the ID for the device, in my case it was 0411:015d
11. Open the usb_main_dev.c in your favorite editor.
12. Search for the id earlier in the form of 0x0411,0x15d.
13. If it is found, you are good to go, else add a line to the end of the list that looks like this.... {USB_DEVICE(0x0411,0x015d)}, /* Baffulo WIFI N USB */ If this line is not present, it will not detect and associate the device to the driver.
14. Save and exit out of your editor.
15. CD back to the main directory.
16. Make the driver, sudo make
17. Install the driver, sudo make install
18. To be on the safe side, at this point I restarted. When the pc came back up, I just used the wireless manager in GNome to setup the network connection.

Some futher issues I ran into was that for whatever reason, traffic was still trying to go out the eth0 and not the new wireless connection. I had to edit my /etc/network/interfaces file and comment out the auto eth0 line. At this point, when the pc starts, the wireless connects and works just fine. There were some other things that were specific to my setup with MythTV, but I'll leave those out unless someone asks.

Hopefully this helps someone.