Skip to main content

Posts

Showing posts from 2008

Getting ASP With JET Access Working On 64-bit vista

There are quite a few issues in getting classic asp scripts working on vista. I want to quickly go over what I did, so that when I need this information available in the future I have an easy place to find it. So to save time I am just trying to get this written as fast as possible and continue on with my work. Sorry for any typos. Install IIS through control panel -> programs and features -> (left panel) “turn windows features on or off” Once the feature listing window populates: expand the “internet information services” item check web management tools and world wide web services …really I went through the options and selected the majority of them. Key ASP related items to make sure you have selected: “world wide web services” -> “application development features” -> ASP I needed windows authentication, so I needed: “world wide web services” -> “sercurity” -> “windows authentication” After tha...

Visual Studio 2005 and Bad Tabulation

I have a dual screen setup with two 20″ Dell LCD screens. I recently changed my primary screen to be vertically orientated. The benefit here is that I can see a more “global” view of the source file I am currently editing. The irritating thing I stumbled upon was tabulation in Visual Studio. I changed my tabs to be 2 spaces instead of two (to make up for my primary screen having less horizontal space). The issue that I had was all old source files were stuck with 4 space tabbing. Here is what I did to fix the issue: Tools>>options (make sure “Show all settings” is checked) Navigate to Text Editor>>All Languages>>Tabs In the Tab box, change the tab size to 2 and indent size to 2 select “ Keep tabs ” (this tells visual studio to not change tabs to spaces) Okay, so now the editor now uses two tabs and I can manually fix code I made before using shift-tab . This doesn’t solve my issue of having old source files stuck with 4 spaces as one tab. What I just figured out ...

Getting .NET COM Interop DLLs Working

I recently finished working on a macro program where the software’s interface is COM.  Everything worked great until I wanted to transfer the macro over to a test client computer.  The program I was writing the macro for requires some registry entries, so I assumed that was all I needed to do.  After about 2 hours of having issues I figured out how to get the macro working on computers other than the one I developed the macro on. What happens automatically when developing COM innerop projects in Visual Studio is that the IDE automatically registers the DLL file behind the scenes, so when the program that is going to use the macro starts up, it can find the DLL file (assuming the “register for COM Interop” is checked in project properties). When transferring over the macro DLL(s), the client computer does not have the correct registry entries, so when the program attempts to load the macro, it will fail because it can’t find the macro DLL(s). Things I learned: regsrv does ...

Working with Regular Expressions in C#

I’ve been working on a program that needs to parse a html file for form data.  So when I was deciding what method to use, a few popped right into my mind. The first being a character by character search through the string.  Parsing through the data and flagging sections that fit the signature of what was being searched for. The second would be automating that by using the built-in string functions to split up the string and drill down until the needed data was extracted. The third, and one I chose to use, was with regular expressions.  This in my mind is the most “poetic” method of the three, which would allow me to make the a robust and reliable function. While I’ve used regular expressions a lot throughout the years. I never seem to remember enough to construct a decent statement. I had recently bought a pocket reference (link below), so I used that to get a statement constructed. It had a total of about 6 pages for C#, but I pretty much got what I needed from it. An...

Esprit Macro With .NET

Edit: I’m having some issues with a second tutorial, so at this point I don’t think this process below is correct.  2nd Edit:  This code should work fine, the issue was when I started using COM objects from Esprit.  There are a few gotchas that need to be taken care of.  I think the primary reason I had issues was due to writing the macro in C# instead of VB (the language the Esprit tutorials have).  I may be writing about it in the future.  If you are interested right now, send a message, or post in the forums. This post will be a little more special interest them most of my posts. I recently started learning how to create macros for a program called Esprit (D.P. Technology). It’s a “CAD/CAM” program. They still use COM/VBA as their plug-in interface, so to write a plug-in in .NET there are a few things that need to be taken care of. Their tutorial that comes with the program goes over setting everything up, but It misses a few steps. Well more likely...

Working With the XML DOM

I’ve been working with server side scripts that rely on xml files to define the structure of the site.  It seems quite fast compared to using a database and also makes direct changes to the structure easy.  My post here is about how to use the DOM in VBSCRIPT/ASP.  Some aspects of how the DOM works are a bit “wiggy” in my opinion, but I’ve figured out a lot of it so far. Here is a quick example on how to parse a file (VBSCRIPT/ASP): function parseXmlFile(filename, byRef emptyVarToFillWithXmlObj)     dim completeFilePath, functionSuccess, filePointer          completeFilePath = getFullPath() & filename          ' Convert the xml file into an xmldoc object     ' First check to see that the file exists     set filePointer = server.createObject("Scripting.FileSystemObject")     if filePointer.fileExists(completeFilePath) then         ' Initialize the xml object ...

Site Revamp Details

Here is a screen shot of the old site.  It served me well for the two years or so that I had it running on blogger.com.  The great thing about blogging is that I can save bits of important information in one place that I can later come back and utilize. The secondary benefit is that other people can also gain something from my writings as well. Now that I’ve taken the plunge to into the world of incorporation, I have had a strong desire to improve my web presence.  My first project being this website revamp. Here is a list of the steps necessary to get from blogger to a custom wordpress blog: – Install wordpress on my computer’s local server ( WAMP ).  This is quite easy if you have messed around with developing websites before.  The major steps to that are 1. create a database (wamp has phpMyAdmin preinstalled, so doing SQL stuff is easy) 2. create a new SQL user that has permissions on the new database.  Once the database is setup, extract the wordpress ...

Silverlight 2.0

I was at a monthly .NET usergroup meeting yesterday. Larry Clarkin ( http://larryclarkin.com/ ) was there, and he was kind enough to give out quite a few copies of Visual Studio 2008. I was one of the ones who needed a copy. Never had the justification to buy it personally. Actually I am using 2005 at work too, but anyways… He talked about Silverlight 2. It has quite a few unique features that make it interesting enough to start “playing” around with. The most interesting aspect to me is the subset of the .NET framework embedded into the Silverlight runtime, which in turn means you can write Silverlight programs in C#/VB.NET (as well as a few other languages). Another plus is that it has built-in form controls. Put those two together and it could be interesting to make some rich web applications with not much difficulty. All this time I though it was just a Flash clone. Check out silverlight.net for more of the specifics.

Learning About .NET Web Access Classes

I mentioned about wanting to start a business in my previous post. Well it looks like I might have my chance. While it isn’t exactly what I was thinking of in my previous post, I foresee many opportunities to flex my programming muscle in this endeavor. Plus, I will be starting up with a good friend, so there is a good chance our motivation will actually produce some results. A piece of software I am starting to research/design/create will be an internal application we will use to automatically extract some government provided public data. The current issue is time. With the amount of data and the requirement of using their web interface, it is not worth the time needed to do it by hand. The only other option would be to buy the data from the government, but that’s just an unnecessary cost seeing as there is a free option available. So I will be writing a program in C# to automatically access a few websites and download the needed data in chunks. I have never delt with .NET’s we...

JavaScript Tip: Submit Form On Enter Key

A common practice with search forms is to have them submit when the enter key is pressed, instead of requiring the user to use their mouse to press the submit button (or using tab key to tab to the submit button). Update: I attempted to find a solution for working in Firefox, but the code I added has not been tested personally. Here is a simple way to do that in JavaScript: First, define a input box: <input name="txtsearchentries" id="txtsearchentries" type="text" size="13" value="" /> Second, create a function to be placed in the head area of the webpage: // see if the user pressed the enter key  // while using a specific control  function submitSearchOnEnter(variable) {     if (window.event) {         // keyCode = window.event.keyCode;         // this doesn't seem to work in Firefox,          // so try the code below...          keyCode = event.keyCode ? event.keyCode :...

Objects in Javascript

Javascript does not use a standard class model. It uses objects that are like associative array structures of data, or so I have read. Regardless of how it works, you can make a class-ish type construct in Javascript. I’ll try to go over the basics here to help anyone who is interested. Objects are defined by creating a new function. Inside the function you can define variables and methods that are attached to the primary function. The primary function is really like the constructor for the object as well. For example: function ObjectExample(constructorParameter1, constructorParameter2) {  //define a variable and assign a constructor value to it  this.variable1 = constructorParameter1;  //you can also define variables with var, but they act differently  this.variable2 = constructorParameter2;            //assigns an instance pointer to a "constructor" variable  var variable3 = this;  //defines a funct...

Javascript Rant

I’ve been working on something recently where I decided to have most of the program run in a client’s browser. It’s basically a blog system that works with that asp-xml-to-access-db class. The clients browser sends/requests information in XML to the server script and everything turned out peachy. I’m overall extremely happy with it. Now that I’m done writing the script. I learned quite a bit more about Javascript that I didn’t know in the past. The initial few days of working with it were tragic. I’m not too fond of Javascript’s (pseudo) object model and lack of a standard class model. While Javascript works and provides a good deal of functionality, it feels dirty. Maybe my fellow “old school” programmers can understand. Besides the object model, the DOM in general is a pain to work with, and hard to find information about (that works in multiple browsers). Inconsistencies, things that logically should work don’t,...

DLL Files And .NET ClickOnce Deployment

I want to deploy one of my .NET apps as a ClickOnce application. The issue is that I am connecting to Oracle (see previous posts here and here ). Connecting to Oracle requires at least, 4 DLL files that generally have to be in the same directory as the EXE file. The issue is that when the program is published, the DLLs are not referenced in any way, so the program won’t work. Then I read about adding the files to the project, so that ClickOnce and the Publish processor will figure out that the DLLs are required and add them to the manifest. Here is the process in Visual Studio 2005: Put the 4 DLL files in their own directory in your solution directory (for ease of use mostly). Add all four files to your project by going to “Project->Add Existing Item…” Click on each DLL file in the solution explorer and then change their property: “Copy To Output Directory” to “Copy Always”. That’s it! Now when I publish or even run the application I don’t have to worry about if the DLL files...

C# .NET Programming Tip: Oracle Connection Revised

Take not that Microsoft will discontinue support for System.Data.OracleClient in .NET 4.0. This method should still work, but it will be depreciated… Now that I have had more time to work with Oracle, I found a better way to connect then described in my previous post . With this new method you can connect to multiple instances in one program by getting rid of that tnsnames file. *Remember that a project reference to System.Data.OracleClient must be added: OracleConnection dbConnection; string connectionString = "Server=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = *******)(PORT = 1521))(CONNECT_DATA = (SID = *****)));Persist Security Info=true;User Id=*****;Password=*****;"; dbConnection = new OracleConnection(connectionString); It’s really that simple. The key here is that the connection string must use the “Server” attribute instead of the “Data Source” one. I ran upon that while looking at the specification on Microsoft’s MSDN documentation site. It’s basically a t...

C# .NET Programming Tip: Types

Figuring out a variable’s type has become more important since now variables can be boxed by their parent class(s) (Where all can be “Object”). It’s nice because it allows for one generalized function to work with many types that perform an action on a common attribute, or first figure out what the object is and then perform the action. That is one of the instances where figuring out a variables type is important. .NET has a built-in function called GetType() which figures out what type a variable is. //loop through the controls in the panel and figure out  //which of the checkboxes are checked  foreach (Control panelControl in newCheckListQuestionPanel.Controls) {       //only continue if this control is a checkbox      if(panelControl.GetType().ToString()      .Equals("System.Windows.Forms.CheckBox") == true)      {           if (((CheckBox)panelControl).Checked == true)  ...

C# .NET Programming Tip: Connecting to an Oracle Database

Take not that Microsoft will discontinue support for System.Data.OracleClient in .NET 4.0. This method should still work, but it will be depreciated… Please view this post for a better way to connect to Oracle. Ugh, I spent a good 6 hours figuring out how to do this! Hopefully this post can save someone some time. Connecting to an Oracle database requires driver files from Oracle. This is true no matter what you use in Visual Studio, it true for System.Data.ODBC or whatever else. This little factoid took me a while to figure out, as I didn’t want to believe that I had to install a 200mb piece of software from Oracle just to connect to one of their databases. Well thankfully I didn’t have to install their standard client. They offer an “instant client” that is quite a bit smaller. They even offer a lite version of the instant client, which is the one I decided to use. The bad thing about it is even that is around 20mb in size. You can download it here: http://www.oracle.com/tec...

C# .NET Programming Tip: Keeping A History With Properties

The program I am writing at work’s primary functionality is a checklist. One of the requested features is the ability to record what actions a user performs on the checklist. So there needs to be some additional code that updates a history table whenever a user makes any changes to the checklist. Let’s define when a history event should fire off: When the user makes a new checklist. When the user updates any property of the checklist. When a user archives a checklist (eg: discard in so many words). Making a history entry when the user makes a new checklist or archives a checklist is easy. There would generally be only one function for each, so just before or after adding or archiving the checklist from the database, the history process is called. What about when the user updates a single field in a checklist? It is important to track those changes, because a single little change is generally the most important (he said, she said situation). In my program checklistprocessor, checkli...

C# .NET Programming Tip: FlowLayoutPanel Mouse Scroll Wheel Not Working

Ahh, some if you may notice that the mouse scroll wheel doesn’t work by default with FlowLayoutPanels. Yeah, this little thing has frustrated me for a while. I usually check the Internet for solutions to problems I have been having. Most likely someone has posted on a message board about the same problem and the problem was solved. Sadly, this method of finding information can lead to numerous dead ends as people don’t post the solution (eg: “Hey I figured it out!”) and fail to say what they did. Or the solution they figure out isn’t “good.” Of course, programming blogs are also a good resource with generally higher quality information, but they don’t seem to be as prevalent in search engines for some reason. Maybe blogs are generally lower traffic? Like I said before, one such issue I was having was with FlowLayoutPanels and the mouse scroll wheel not scrolling them when the panels had scroll bars. Doing a search on the internet came up with close to nothing. Most “solutions” ...

C# .NET Programming Tip: Using the Tag property of controls

I’ve been doing C# programming at my job lately. Throughout the process I’ve hit a few little walls that were difficult to find answers for and thought writing down the solutions here would be good for myself any anyone who happens to find this by-way-of search engine. So as I come upon these little bits of useful harder-to-find information, I’ll write something here about it. Creating windows form controls programmatically and passing data between class instances was one such issue. I did a number of searches on Google and didn’t really find much help. The main suggestion was to create an EventArgs class that passes events or some such thing. That was a really involved process that didn’t seem like it was worth the effort to implement. I then created my own static global event class where anything in the program could pass an unlimited number of parameters. Once the parameters were accessed, they were deleted from the static Dictionary that stored everything. Well actually it wa...

Is object orientated PHP scripting worth the effort?

I’m currently creating a movie review website in PHP an SQLite. I’m taking a very object orientated approach. For example, all database access goes through an object. Adding a review is as simple as calling a function with the proper data. Here is the function header: addReview($assocArrayReviewData, $assocArrayReviewBlockData) Each parameter is an associative array that corresponds to fields in the database. While I don’t want to get into too much detail, the second variable is actually an array of arrays, where each one holds a block of review information (eg: “What the box says”, “funny quotes”, “My thoughts”). The best thing about is is that once I create the administration interface I can just call that one function with the correct parameters and bam, a new review. The class also has a built-in search function (that could be used on the internal or external site). My next class that I created for primarily for the administration area. It’s an html tag class object. You might...