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