Archive for May, 2010

ASP, Microsoft SQL and AJAX

Well I haven’t done web programming for awhile now and getting back into it was a slow start but I was able to get through it. I’ll have to admit, at first Google was my best friend. However, soon I found that the MSDN documentation is actually not too bad if you understand the programming syntax and wording (meaning you’re not a total novice at programming).

Many articles can be found online that tell you how to make your first ASP page and connect it to MS SQL, so I’ll just summarize the bits that took me the most time:

1. Web.config:
This is a file that is used to house various configurations. I used it to turn off the customErrors so that I could do debugging. The other item I configured here was the connectionStrings – used to create a connection to the database.

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
<connectionStrings>
<add name="connName" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=dbName;Persist Security Info=True;User ID=sa;Password=password" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

2. asp:SqlDataSource:

This is the container used to define your SQL Query. The main item to note with this is the ConnectionString and ProviderName settings. Because we have defined these within the Web.config file, we merely direct the container to retrieve the values from the Web.config file.

<asp:SqlDataSource ID="generatedDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:connName %>" ProviderName="<%$ ConnectionStrings:connName.ProviderName %>" />

3. asp:Panel and asp:DataList:
These two items are the containers for the items that are returned from your SQL Query. I have used the Panel to enclose the DataList in order to enable scrollbars. By default DataList only supports a limited list of formatting options. These can be found in the MSDN documentation as well. However in order to show scrollbars in a pre-defined area a Panel must be used.

<asp:Panel runat="server" BorderColor="Black" Style="width: 650px; height: 400px; overflow: auto">
<asp:DataList ID="generatedDataList" DataSourceID="generatedDataSource" OnLoad="CheckClicked" runat="server" RepeatColumns="3">
<ItemTemplate><%# Eval("tableCol1") %></ItemTemplate>
</asp:DataList>
</asp:Panel>

4. Script generated SQL Query:
The final item that fell in place for my particular project was the script generated SQL Query. I was able to generate the Query from multiple results returned by multiple CheckBoxLists, however in order to re-display the resulting script generated SQL Query I had to set it to the DataList. To do this, assign the sqlDataSource a SelectCommand value.

generatedDataSource.SelectCommand = SQLQuery;

Have fun!

Making things go automagically

Was working away at work today and required to have a PERL script to be loaded every Friday. To do this, I had to employ the help of crontab.

usage:  crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
(default operation is replace, per 1003.2)
-e      (edit user’s crontab)
-l      (list user’s crontab)
-r      (delete user’s crontab)
-i      (prompt before deleting user’s crontab)
-s      (selinux context)

  • A minute, expressed as a number from 0 through 59.
  • An hour, expressed as a number from 0 through 23.
  • A day of the month, expressed as a number from 1 through 31.
  • A month of the year, expressed as a number from 1 through 12.
  • A day of the week, expressed as a number from 0 through 6 (with 0 standing for Sunday).

Example of usage includes:

5 6 * * 1-5    command
10 8,14 * * 1-5  command

There will always be 5 specifications. A static number, static numbers with commas in between, a range between numbers with a dash or an asterisk to represent all possible values.

Filezilla password recovery

Recently I had to recover passwords from a dead windows installation. Be it good or bad, Filezilla stores its passwords in plain text! I was able to get all my sites, but users should be aware that the passwords are in no safe from prying eyes…

The following files are what you need to know about:

filezilla.xml – Stores most recent server info including password in plaintext.
recentservers.xml – Stores all recent server info including password in plaintext.
sitemanager.xml – Stores all saved sites server info including password in plaintext.

These files can usually be found in the following directories:

Windows XP/2K: “C:\Documents and Settings\username\Application Data\FileZilla”
Windows Vista: “C:\Users\username\AppData\Roaming\FileZilla\”
Linux: “/home/username/.filezilla/”

List of English stop words

Stop words are basically words that should not be indexed in a search. This is because these words are commonly used and most likely will not provide search results that will be helpful to the user. The following is a list of English stop words that I have used:

a’s, able, about, above, according, accordingly, across, actually, after, afterwards, again, against, ain’t, all, allow, allows, almost, alone, along, already, also, although, always, am, among, amongst, an, and, another, any, anybody, anyhow, anyone, anything, anyway, anyways, anywhere, apart, appear, appreciate, appropriate, are, aren’t, around, as, aside, ask, asking, associated, at, available, away, awfully, be, became, because, become, becomes, becoming, been, before, beforehand, behind, being, believe, below, beside, besides, best, better, between, beyond, both, brief, but, by, c’mon, c’s, came, can, can’t, cannot, cant, cause, causes, certain, certainly, changes, clearly, co, com, come, comes, concerning, consequently, consider, considering, contain, containing, contains, corresponding, could, couldn’t, course, currently, definitely, described, despite, did, didn’t, different, do, does, doesn’t, doing, don’t, done, down, downwards, during, each, edu, eg, eight, either, else, elsewhere, enough, entirely, especially, et, etc, even, ever, every, everybody, everyone, everything, everywhere, ex, exactly, example, except, far, few, fifth, first, five, followed, following, follows, for, former, formerly, forth, four, from, further, furthermore, get, gets, getting, given, gives, go, goes, going, gone, got, gotten, greetings, had, hadn’t, happens, hardly, has, hasn’t, have, haven’t, having, he, he’s, hello, help, hence, her, here, here’s, hereafter, hereby, herein, hereupon, hers, herself, hi, him, himself, his, hither, hopefully, how, howbeit, however, i’d, i’ll, i’m, i’ve, ie, if, ignored, immediate, in, inasmuch, inc, indeed, indicate, indicated, indicates, inner, insofar, instead, into, inward, is, isn’t, it, it’d, it’ll, it’s, its, itself, just, keep, keeps, kept, know, knows, known, last, lately, later, latter, latterly, least, less, lest, let, let’s, like, liked, likely, little, look, looking, looks, ltd, mainly, many, may, maybe, me, mean, meanwhile, merely, might, more, moreover, most, mostly, much, must, my, myself, name, namely, nd, near, nearly, necessary, need, needs, neither, never, nevertheless, new, next, nine, no, nobody, non, none, noone, nor, normally, not, nothing, novel, now, nowhere, obviously, of, off, often, oh, ok, okay, old, on, once, one, ones, only, onto, or, other, others, otherwise, ought, our, ours, ourselves, out, outside, over, overall, own, particular, particularly, per, perhaps, placed, please, plus, possible, presumably, probably, provides, que, quite, qv, rather, rd, re, really, reasonably, regarding, regardless, regards, relatively, respectively, right, said, same, saw, say, saying, says, second, secondly, see, seeing, seem, seemed, seeming, seems, seen, self, selves, sensible, sent, serious, seriously, seven, several, shall, she, should, shouldn’t, since, six, so, some, somebody, somehow, someone, something, sometime, sometimes, somewhat, somewhere, soon, sorry, specified, specify, specifying, still, sub, such, sup, sure, t’s, take, taken, tell, tends, th, than, thank, thanks, thanx, that, that’s, thats, the, their, theirs, them, themselves, then, thence, there, there’s, thereafter, thereby, therefore, therein, theres, thereupon, these, they, they’d, they’ll, they’re, they’ve, think, third, this, thorough, thoroughly, those, though, three, through, throughout, thru, thus, to, together, too, took, toward, towards, tried, tries, truly, try, trying, twice, two, un, under, unfortunately, unless, unlikely, until, unto, up, upon, us, use, used, useful, uses, using, usually, value, various, very, via, viz, vs, want, wants, was, wasn’t, way, we, we’d, we’ll, we’re, we’ve, welcome, well, went, were, weren’t, what, what’s, whatever, when, whence, whenever, where, where’s, whereafter, whereas, whereby, wherein, whereupon, wherever, whether, which, while, whither, who, who’s, whoever, whole, whom, whose, why, will, willing, wish, with, within, without, won’t, wonder, would, would, wouldn’t, yes, yet, you, you’d, you’ll, you’re, you’ve, your, yours, yourself, yourselves, zero

Have fun!

MySQL database restoration error

So I was trying to restore a backup database from a .sql file through the following command:

mysql database < file.sql

And an error resulted:

Got a packet bigger than ‘max_allowed_packet’ bytes

This is most likely due to the fact that there are large images and other files in the database causing problems. I had to edit the MySQL configuration files and added the following:

vim /etc/my.cnf

set-variable=max_allowed_packet=xM

For my particular issue, I had to change x to 512. This may vary depending on how large your files are.

Microsoft Dynamics CRM 4.0 woe part 2

Microsoft Dynamics CRM, this is truly a beast of a software. Installation is often a hit or miss based on what is currently installed on the PC.

Recently I had to install CRM onto a PC plagued with problems. There were updates for Windows, software half installed and remaining files from previously installed software. To add to that the PC was at a remote location and required a VPN connection back to the main office. Refer to my other posting to see how that was resolved.

Thinking that I had resolved the problem, I had left the user to the PC – boy was I wrong. CRM did not like the fact that I had previously logged into that PC with my account (when I was foolishly testing it). Basically, the CRM checks if there is already an user installed into the SQL server and if there is, CRM will not allow another user. Attempting to resolve this by removing the data proved to be a futile effort. I basically had to uninstall everything including CRM and the SQL Server to allow the user to register himself on Outlook with the CRM plugin.

Hopefully, this time around, the issue is finally laid to rest!