Exploring the depths and potentials of ASP.NET RSS 2.0 or Subscribe to .BenRush by Email
 Tuesday, February 21, 2006

System.AccessViolationException was unhandled by user code
  Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
  Source="Oracle.DataAccess"

What a pathetic exception detail! The cause of this is not calling .Read() on your OracleDataReader before calling .GetValue(). Wonderfully insightful error message there!


kick it on DotNetKicks.com
Tuesday, February 21, 2006 3:34:19 PM (Central Standard Time, UTC-06:00)  #    Comments [2] - Trackback
Computing | Ranting

Well, this drove me bonkers. I distinctly remember trying the method that finally worked before and I distinctly remember it not working before - but it suddenly started working now, so I figured I might as well post and hopefully save others time.

The CreateUserWizard control uses template controls to perform its forward/backward magic. But what if you want to reset the text box values after you have successfully created a user (so that you can click "continue" and have it go back to the original page so you can create more). After trying the method you'll see in a second, I tried this (as a hard-coded attempt):

CType(Me.CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName"), TextBox).Text = ""
CType(Me.CreateUserWizardStep1.ContentTemplateContainer.FindControl("Password"), TextBox).Text = ""
CType(Me.CreateUserWizardStep1.ContentTemplateContainer.FindControl("ConfirmPassword"), TextBox).Text = ""
CType(Me.CreateUserWizardStep1.ContentTemplateContainer.FindControl("Email"), TextBox).Text = ""
CType(Me.CreateUserWizardStep1.ContentTemplateContainer.FindControl("Question"), TextBox).Text = ""
CType(Me.CreateUserWizardStep1.ContentTemplateContainer.FindControl("Answer"), TextBox).Text = ""

This did NOT work - I have a feeling that the control remembers the values and, just before rendering out the HTML resets thos values to what it knows internally. The solution (which I honestly remember trying earlier) is:

Me.CreateUserWizard1.UserName = ""
Me.CreateUserWizard1.Email = ""
Me.CreateUserWizard1.Question = ""
...

That's a %&$**$ hour of my life I can't get back.


kick it on DotNetKicks.com
Tuesday, February 21, 2006 12:41:26 PM (Central Standard Time, UTC-06:00)  #    Comments [4] - Trackback
Computing
 Monday, February 20, 2006

"Reality is merely an illusion, albeit a persistent one." ~Albert Einstein

...that's all fine and dandy, but when it smacks us in the face with a task at hand (and, typically, hundreds of tasks at hand), how are we to survive the onslaught? How are we to stay productive? How are we to maintain our sanity in the face of all the things we have to get done, especiall when we watch them slip away? These are questions I've been asking myself lately and I've started developing thoughts on what, in reality, are the biggest killers of effective time/life management.

The biggest thing that hit me, as I was freaking out a particular deadline, was that the biggest killer of my own effeciency in life (and thus time), is stress - but not just any kind of stress. If we were to really observe stress and what it means, we'd see that it permeates every inch of our lives: we have stress to perform, we have stress to wake up and get to work, we have stress to do just about anything. In fact, even in the most basic sense, if we didn't have stress - we'd get nowhere. Stress is good, then - so when does it become a bad thing? In my opinion, it's when we start stressing out about it.

There always appears to be the odd side-effect of being a conscious creature where it's rarely "the problem" that is our problem, but the problems we make surrounding "the problem". These self-created problems are the ones that got in our way and made us ask, after we fixed the problem, "What really took me so long?" We are mental beings floating about in a physical world, and so it makes sense that 90% (or, probably greater) of all our troubles are self-inflicted and self-sustained. When I'm stressed, I get myself stressed about being so - because I get wound up about being anxious, and about how I'm going to make the deadline. The deadline is a stress to get a particular task done, but how stressed you get about it is up to you. For us computer programmers - we can define it as a recursive problem (and eventually we'll blow our stack).

When we're stressed we think less and panic more, we sleep less and therefore daydream more, we eat worse and therefore make ourselves sick, we fool around more in an attempt to hide that which stresses us - only to wake up and have it there again. When faced with a stress, then - try to observe how you react to it (the stress) and how stressed you get about it. When you feel the tasks mounting, do you start getting panic and start running around the house trying to find keys you threw somewhere as you were trying to accomplish something twenty minutes ago that you were also stressed about? Work with yourself instead of against yourself.

...just try observing how you stress about stress next time and wonder how much of your current problem is of your own making. How good are you at looking into a particular problem, and saying to yourself "It is what it is and this is the task, so let's solve it" with the least amount of stress as possible.


kick it on DotNetKicks.com
Monday, February 20, 2006 11:04:57 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
Ranting

...and that's because Oracle doesn't support booleans! I completely forgot about this and re-realized how unbelievably idiotic this is!!! AARGH! I'm porting code over that went against the ODBC drivers for Oracle (which must have done something special to allow booleans) to the raw Oracle provider (ODP.Net).


kick it on DotNetKicks.com
Monday, February 20, 2006 1:17:30 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback


Hari found a page full of cool ASP.Net articles here.


kick it on DotNetKicks.com
Monday, February 20, 2006 12:05:08 AM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback

 Sunday, February 19, 2006

...I found this article an interesting read. Whether you own a Mac or a PC you really should exercise a decent amount of caution when running programs, etc; I mean, it's just common sense. The thought that one operating system is somehow immune to virus attacks is idiotic.


kick it on DotNetKicks.com
Sunday, February 19, 2006 11:57:11 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback


http://www.microsoft.com/downloads/details.aspx?familyid=f22e51e5-b82e-4a54-9ccc-3418e0bf5639&displaylang=en


kick it on DotNetKicks.com
Sunday, February 19, 2006 11:22:12 AM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
Computing
 Saturday, February 18, 2006

I encountered a user interface "problem" today. At work I have multiple monitors, and at home I only have the one on my machine (I own Dell 9300, and so it's my desktop at both places). As a result, sometimes when going back and forth between the multiple monitors and my single, I sometimes wind up with an app that'll draw itself OFF the desktop window when I suddenly fire it up on my single monitor (if I open the app, it'll show up, but like on some wacky negative x/y coordinate way off in la la land).

There's a way, apparently, to bring the window BACK onto my visible desktop through Alt-SPACE-M or something like that, but I couldn't get it to work for some odd reason. So I wrote an app that'll simply re-align all my desktop windows to the 0/0 x/y position. It's a rough hack because all I wanted was to get my app to draw its window in a sane position again - so, I wouldn't take the code as-is and use it wherever. It worked for me, and it was an interesting way to step back and realize "Man, I'm a geek".

using System;
using System.Collections.Generic;
using System.Text;

namespace StraightenWindows
{
    class Interop
    {
        public delegate System.Boolean EnumWindowsProc(
            System.IntPtr hWnd,
            System.Int32 lParam);
        [System.Runtime.InteropServices.DllImport("user32")]
        public static extern System.Boolean EnumDesktopWindows(
            System.IntPtr hDesktop,
            Interop.EnumWindowsProc lpfn,
            System.Int32 lParam);
        [System.Runtime.InteropServices.DllImport("user32")]
        public static extern System.Boolean IsWindow(System.IntPtr hWnd);
        [System.Runtime.InteropServices.DllImport("user32")]
        public static extern System.Boolean IsWindowVisible(System.IntPtr hWnd);
        [System.Runtime.InteropServices.DllImport("user32")]
        public static extern System.IntPtr GetParent(System.IntPtr hWnd);
        [System.Runtime.InteropServices.DllImport("user32")]
        public static extern System.Int32 GetWindowText(
            System.IntPtr hWnd,
            [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr, SizeConst = 255)]
            System.Text.StringBuilder lpString,
            System.Int32 nMaxCount);
        [System.Runtime.InteropServices.DllImport("user32")]
        public static extern System.Boolean MoveWindow(
            System.IntPtr hWnd,
            System.Int32 x, System.Int32 y,
            System.Int32 nWidth, System.Int32 nHeight, System.Boolean bRepaint);
    }
    class Program
    {
        static System.Boolean EnumWindowsCallback(System.IntPtr hWnd, System.Int32 lParam)
        {
            // verify it's a window and it's visible
            if (Interop.IsWindow(hWnd) && Interop.IsWindowVisible(hWnd))
            {
                // verify it's a parent window
                if (Interop.GetParent(hWnd) == System.IntPtr.Zero)
                {
                    // the get parent can also return zero on error, so check for that condition.
                    if (System.Runtime.InteropServices.Marshal.GetLastWin32Error() == 0)
                    {
                        System.Text.StringBuilder sb = new StringBuilder(255);
                        if (Interop.GetWindowText(hWnd, sb, 255) > 0)
                        {
                            Console.WriteLine("Window " + hWnd.ToString() + " has text '" + sb.ToString() + "'");
                            Console.WriteLine();
                            Console.WriteLine();
                            // fix
                            Interop.MoveWindow(
                                hWnd,
                                0, 0, 500, 500, true);
                        }
                    }
                }
            }

           
            return true;
        }
        static void Main(string[] args)
        {
            Interop.EnumWindowsProc p = new Interop.EnumWindowsProc(EnumWindowsCallback);
            Interop.EnumDesktopWindows(System.IntPtr.Zero, // use current desktop
                p, 0);
            Console.Write("Press any key to continue...");
            Console.ReadKey();
            return;
        }
    }
}


kick it on DotNetKicks.com
Saturday, February 18, 2006 3:27:45 PM (Central Standard Time, UTC-06:00)  #    Comments [2] - Trackback
Computing | Personal Adventures

Computers Blogs - Blog Top Sites

Archive
<February 2006>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
2627281234
567891011
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009
Benjamin Rush
Sign In
Statistics
Total Posts: 444
This Year: 0
This Month: 0
This Week: 0
Comments: 128
Themes
Pick a theme:
All Content © 2009, Benjamin Rush
DasBlog theme 'Business' created by Christoph De Baene (delarou)