Tuesday, February 26, 2013

SQL Delphi Data Components


I am going to tell you briefly of a fabulous product from Devart.com: their Data Access Components for MySQL (MyDac): http://www.devart.com/mydac/
I was working in a language called Pascal in an IDE called Delphi. Not widely used, however, quite powerful. I created a point-of-sale system and because we were rushed to market, who isn’t these days, I did not look around for any database components. I figured the components Delphi had were fine.
The problem arose soon after we went live – Memorial Day weekend. 100+ terminals all banging away at MySQL and my POS system. Response to/from the DB was very slow. June went by without a solution. July went by – a little better with some tweaks to code, but not by much.
Finally, on August 1st I found MyDac from Devart. I downloaded their trial version of the MyDac components. They installed without issue and I ran some basic tests in only a few minutes. It was completely user-friendly to use. Their help file is detailed and organized but I did not find this out until months later when I used MyDac to do other, more complicated tasks.
I had built my database classes in such a manner where I only had to replace the units/libraries from Delphi’s to Devart’s. Then, I cast my components as MyDac: TDatabase to TMyDatabase and TTable as TMyTable for example.
I compiled and it ran!
I had to make ZERO changes to my code.
I ran some tests locally with success. Then, contacting the client indicated I wanted to put this test onto one or two terminals. Eagerly, they agreed. Moments after it was installed, they called back and asked if something was wrong? I asked them to explain and they stated it was running so fast, they thought nothing was being saved or updated in the database. I assured them through reports, indeed the data was there – it was just amazingly fast now.
Did I tell the client it was Devart who I have to thank for this great performance improvement over the standard Delphi components? Of course I didn’t. They think I just found the magic solution and thought very highly of me and were very happy.
I was happy too.
Devart, you saved my butt back then and probably the product and client.
I am looking to purchase their products as they are clearly well done and superior to the standard components.
Thank you Devart.

Monday, May 14, 2012

Cisco EA3500 Router Purchase

The router we currently had - not sure of the make/model - was apparently about to die. I did some quick searches on-line for routers and found a clump from Cisco, Linksys and D-Link, as was expected. I was more interested in the price than the brand as these were the brands I would stick with anyway.

Being the patient person, I did not order on-line I went down to Office Depot because we had a gift card from a previous purchase/return.

We purchased the Cicso EA3500 for the following reasons:
1) Dual band
2) Four-ports
3) USB port

Several models had the first two but only models above $100 had the USB port.

FYI: Office Depot took our $10 off a $50 purchase we received from Office Max. Thank you Office Depot.

Setup: Well, this is where I was surprised. I had my 13-year old son do it and all I did was take it out of the box and watch.

1) Start the setup program with the provided CD.
2) Plug the router in and make all the connections (I told him to watch what cord was the WAN cord from the previous router)
3) Press continue on the installation program
4) Provide a password for the wireless
5) Reboot router
Done!

Thank you for a pleasant installation, Cisco!

Tuesday, April 17, 2012

Freeing Delphi Dynamic Arrays

This post is about freeing dynamic arrays in, Delphi.

In, Delphi, as in others, dynamic arrays useful in many instances. Here is a good link on a basic understanding
http://delphi.about.com/od/beginners/a/arrays.htm This is not what this post is about.

Let's declare a dynamic array and we will use the same variables as the link above so to make it easier to understand


var
  Students : array of string; 
  nCounter: integer;
begin
  // set the length to something
  SetLength(Students,5); // this will hold six students
  // loop through and load the array with some data
  for nCounter := Low(Students) to High(Students) do
  begin
    Students[nCounter] := 'My student #: ' + inttostr(nCounter);
  end;

  // do something
  // way one to free array
  Students := nil;
  // way two to free array
  SetLength(Students,0);
  // way three to free array
  Finalize(Students);
end;


There you go!

Wednesday, April 4, 2012

Enter ASCII Characters

Several ways to accomplish entering ® or © into text. In Word® you can select it from the fonts. You can also use the Character Map in Windows and find your character and hit copy.

The cool way is to hold down the ALT key and then, using the keypad, type the appropriate ASCII number. For example:
® = ALT + 0174
© = ALT + 0169

You can use this for any of the ASCII characters.

Happy typing.

Tuesday, November 29, 2011

TSQL Delete All Data

So you want to delete all the contents of the tables in your MS SQL database. You could drop and create the database. You could also drop and create the tables within the database. Then, you could iterate through all the tables in the INFORMATION_SCHEMA and delete all the rows with a TSQL script.

Here is the script I used:

USE [YourDatabase];
GO
SET NOCOUNT ON;
DECLARE @MyTableName varchar(100);

DECLARE MyCursor CURSOR
  FOR SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
  WHERE TABLE_CATALOG = 'YourDatabase' AND TABLE_SCHEMA = 'dbo';
OPEN MyCursor;
FETCH NEXT FROM MyCursor INTO @MyTableName;

WHILE @@FETCH_STATUS = 0
BEGIN
  EXEC ('DELETE FROM ' + @MyTableName);
  FETCH NEXT FROM MyCursor INTO @MyTableName;
END;
CLOSE MyCursor;
DEALLOCATE MyCursor;

Tuesday, August 23, 2011

SQL Server Full-Text Searching

Sometimes, a blog will contain information you wrote on a topic. Other times, a blog will be a posting about what others have already put together.

This post is the latter.

Recently, the opportunity arose to research how to search binary data in a database. The constraints were the document was stored in the table and it needed to work with SQL Server or Oracle. This post will, focus mostly on SQL Server.

This article shows in great detail how to setup the full-text indexing and provides great explanation as to many of the options within the syntax.

The article uses the Adventure Works database. If you need the Adventure Works database.

Then, after this was tested out, this article was found on Google type searching within a SQL Server.

And finally, some information on Google searching.

All these links were last tested: 23 Aug 2011.

Friday, August 19, 2011

Delphi Sets

A simple example of doing enumerator sets in Delphi. There are several other examples available, I will provide links at the end of this post.

1) Declare an enumerated type:
TeDaysOfWeek = (eDoWMonday, eDoWTuesday, eDoWWednesday, eDoWThursday, eDoWFriday, eDoWSaturday, eDoWSunday);

2) Declare a set of the enumerated type:
TeDaysOfWeekSet = set of TeDaysOfWeek;

3) Declare a variable to work with the set:
var
  eDOWSetWork: TeDaysOfWeekSet ;

4) Add items to the working set. Say the application is indicating what days the doctor is available:
// sets the set to empty
eDOWSetWork := [];
// add values to the set
if (some_boolean_values) then
begin
  eDOWSetWork := eDOWSetWork + [eDoWMonday, eDoWTuesday];
end;
if (some_other_condition) then
begin
  eDOWSetWork := eDOWSetWork + [eDoWWednesday];
end;

What you are doing with the "set = set + enumerator" is adding values into the set. You could also set the set:
eDOWSetWork := [eDoWWednesday];
This would replace any values in the set with just eDoWWednesday.

This sets the set for use, now we need to use it for comparison or other behavior:
5) Implement behavior:
procedure DoSomething(p_eDOWSetWork: TeDaysOfWeekSet);
begin
  if (eDoWWednesday in p_eDOWSetWork) then
  begin
  end;
end;

Other links for sets:
http://delphi.about.com/od/beginners/a/delphi_set_type.htm
http://www.delphibasics.co.uk/Article.asp?Name=Sets
Sets in Delphi Prism: http://prismwiki.codegear.com/en/Sets


Friday, August 12, 2011

Move to Top of Page


Tap the bar at the top of the iPhone page, whatever the page to return to the top - the gray part in this image:

Home Button and More


Today's tip is something my kids showed me the other day.

Your iPhone and other i Devices often leave apps open - even after you "close" the apps. By close, I mean you are no longer using the app. By leave open, I mean the app is still running, you do not see the app running.

Why close an app? When an app is open, though not visible, it is still using resources on the device. It may be communicating with the Internet or other apps and devices, using up battery and possibly other resoruces.

To see what apps are open and running, hit the Home button twice. On the bottom, you will now see a list of apps currently open.


To close the apps, hold down an icon on the bottom row until you see a "-" appear. When you see the "-" appear, touch the "-" icon and the app will close. This will appear as though you are deleting the app from the device, but it will only be closing the app.

Shopping Apps


ShopSavvy
Frucall
Postabon
Point Inside
Coupon Sherpa

Monday, August 23, 2010

Using web.config To Store Connection String

So, maybe this was written about about 100K times, however, I thought it would be good to add it again as I just helped someone add this functionality

You can add any connection string, this example will show for Microsoft Access - yes people still use this database.


  1. Open the web.config file.
  2. If you do not see a section called , then add one. The section should be inside the section.
    You may see , if this is the case erase this line and start typing:
    . If you have code sense turned on, very quickly you should be able to hit the key and you will end up with

    If so, put the cursor between the ">" and the "<" symbols and hit enter. You will end up with

    start typing here
  3. Okay, in the "start typing here, area, insert:

    I like to add this line to ensure my connection is not duplicated as I add it
  4. Now, just below this line, enter this line:
  5. Note the "conMyConnection" from the remove name and the add name should match
  6. Now, in your VB code, you can define a string such as:
    Dim conn As New OleDbConnection(ConfigurationManager.ConnectionStrings("conMyConnection").ConnectionString.ToString)
  7. Note again the "conMyConnection" matches all the way through
  8. So, if you need to change the location of your database, just change the web.config file and all calls to the database will find the new path.
Happy Databasing

Daniel

Wednesday, February 17, 2010

Word Tips

Print Multiple Copies of Individual Pages

Most Word users know how to print multiple copies of a document: Just change the "Number of copies" setting to the amount you need, then click OK.



Okay, but what if you want to print multiple copies of select pages? For example, suppose your five-page document ends with a registration form. You need only one copy of the first four pages, but you want three copies of page 5.



The secret lies in the Page range section of Word's Print dialog. As you may know, by selecting the Pages option, you can specify which pages of a document you want for this particular print job. For example, you might enter 1-3, 5, which would print pages 1, 2, 3, and 5.



But you can also use this option to print multiple copies of individual pages. So in my aforementioned example, to get three copies of page 5 and one copy of everything else, you'd enter 1-4, 5, 5, 5.



In other words, each time you repeat any given page number in that Pages field, Word will print an extra copy of that page.



Strip Hyperlinks From Pasted Text

I'm constantly copying text from e-mails, Web pages, and other online sources into Word documents, and always with the same result: a bunch of unwanted hyperlinks for Web links and e-mail addresses. Good luck plumbing the depths of Word's menus to find a way to remove these links.



One solution is to right-click any linked item and choose Remove Hyperlink, but that's a pretty slow method if you have multiple links you want to, well, unlink.



Thankfully, there's a fast, easy, and automated solution: Select the entire block of text, then press Ctrl-Shift-F9. Presto: no more hyperlinks. All that's left behind is plain text. To my knowledge, this works in all versions of Word.



Quickly Add Filler Text to Your Document

Do you ever need to add some filler text to a Word document? You know, the "lorem ipsum" stuff you routinely see in document mock-ups, presentation materials, and the like.



There's a secret Word shortcut that makes this surprisingly easy. Just type (or copy and paste) either of the two following lines and then press Enter:



=rand()



=lorem()



The first one generates three paragraphs' worth of random text; the second produces three paragraphs of the aforementioned lorem ipsum gibberish. You can repeat as necessary to add more filler text to your document.



Didn't work? You may need to venture into Word's settings to enable a certain setting. Here's how to do so in Word 2007:



Click the Office button, then select Word Options, Proofing, AutoCorrect Options.

Click the checkbox next to "Replace text as you type."

Change Text Size Using Only Your Keyboard

I've got a keyboard shortcut for you that sidesteps the hassle of reaching for the mouse, then fiddling with toolbar menus, every time you want to adjust the font size.



Using your Home or End keys and/or the arrow keys, place your cursor at the start of the text you want to resize.

While holding down the Shift key, press the right or down arrow to select a character or enter line, respectively. Keeping going until you've selected all the text you want to resize. (Bonus tip: Adding the Ctrl key to the mix while tapping the right arrow selects an entire word at a time.)

Press Ctrl-] (that's the right-bracket key) to increase the selected text one point size. Press Ctrl-[ to decrease it accordingly. Repeat until the text reaches the size you want.

This sounds a bit more complicated and time-consuming than it is. Trust me: Once you start using the keyboard this way, you'll spend a lot less time reaching for the mouse.


Source