Saturday, March 29, 2008

Typos!

I was just looking through my blog. I noticed quite a few typos and some terrible English. Ugh. Fixed what I saw, but I imagine there could be quite a bit more disbursed throughout the older posts.

I must have been writing some of these posts in a daze or something. Honestly, I am a native English speaker if you thought otherwise!

My educated guess as to the problem:
- My interest in Japanese is screwing up my language thought process a bit.
- The library of programming syntaxes I try to force into my memory.
- Not proofreading my posts 3+ times before posting them.

Thursday, March 27, 2008

ASP VBScript Database Accessor Class

I've got some limitations with a web server I've been working with. It doesn't have support for .net assemblies, so I can't write web applications in Visual Studio 2005. This leads me to think of creative ways to handle functionality.

Anyways, I came up with an idea of creating a class in VBScript (ASP), where I could send post data to a script on the server that would in-turn access the database file and do what it needs to do. I took it one step further, where all talk between client and server is XML. So the client sends "mock" SQL in the from of XML and in turn receives a response in XML saying if it worked, or returning data from the database.

I'm releasing the code under the Lesser GPL here (revised 04/09/2008):
http://www.netnobi.com/software/lgplaccessdatabase.php

I fixed quite a few errors that I ran into while using the class recently. I also added a few features to the select type xml that can processed by the class.

Saturday, March 1, 2008

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:
1. Put the 4 DLL files in their own directory in your solution directory (for ease of use mostly).
2. Add all four files to your project by going to "Project->Add Existing Item..."
3. 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 are where they should be.

C# .NET Programming Tip: Oracle Connection Revised

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 tnsnames string with a few more attributes like user id and password. Just remember that:
host is the name of your server or ip address, sid is the name of your database meaning the *** part of ***.world, and of course the user id and password are your login credentials.

There is another helpful step that I will be posting about. It relates to ClickOnce and the 4 DLL files that you need to connect to Oracle.