Dave's Technophorical Times

A blog about Microsoft's Technologies!
SharePoint :: MVC :: ASP.NET :: IIS :: SQL Server :: Visual Studio :: MS Access

From this guys site: http://www.mysharepointadventures.com/2012/11/removing-references-to-old-unused-databases-in-sharepoint-2010/

Over time, as you create / remove service applications, there is a tendency for SharePoint to retain a list of databases that are no longer in use but still referenced in the SharePoint Config database. If you try to remove the database on the SQL server without first removing it from SharePoint, you will get an event logged periodically on your SharePoint Web Front End about being unable to find / access the missing database.

Solution

To remove the orphan databases / databases that are no longer in use.

Run SharePoint Management Shell

Run the command

Get-SPDatabase | fl name,id

Locate the database you wish to remove and copy its ID.
Run the command

$db = Get-SPDatabase (id)
$db.Delete()

Now type Get-SPDatabase again, you should see that the database(s) have been removed.



From this guys great Blog! http://blogs.technet.com/b/meamcs/archive/2012/10/23/renaming-sharepoint-2010-search-service-database-name.aspx

In this post I’m planning to walkthrough the practice of changing the SharePoint 2010 Search Service Database names as you might need it in the following scenarios:

  • Replacing the Search Service Application Databases Names that Includes GUID’s to a friendlier name.
  • The Database Admin in the Organization is planning to change the naming convention of all the Databases names in the Data Center.
  • If you are planning to move from one Farm to another that has a different Naming Convention.

You have many options to do this practice as shown in the below figure, but in this post I will walkthrough the preferred steps only to make it simple and clear:

 

 

Renaming Property & Crawl DBs using Central Administration:

Verify that the user account that is performing the procedure is a member of the Farm Administrators SharePoint group.

  1. In Central Administration, click Application Management.
  2. On the Application Management page, click Manage service applications.
  3. Click the name of the Search Service Application.
  4. On the Search Administration page, click Modify.
  5. On the Manage Search Topology page, the following three databases are listed: Administration, Crawl, and Property. You can point to renamed or moved Crawl or Property databases by using this procedure.
  6. Click the database that you want to change, and then click Edit Properties.
  7. In the Database Server text box, type the new server location if there is one; in the Database Name text box, type the new name for the database; and then click OK.
  8. On the Manage Search Topology page, click Apply Topology Changes.

 

Notes:

  • You cannot point to a renamed or moved Search Administration database by using Central Administration.
  • It might take several minutes for the changes to take effect.

 

Renaming Search Service Application Database using PowerShell:

Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

  1. On the Start menu, click All Programs.
  2. Click Microsoft SharePoint 2010 Products.
  3. Click SharePoint 2010 Management Shell.
  4. At the Windows PowerShell command prompt, type the following commands:
    1.  
      • Point the Search Administration database to its new name or location.
$searchapp | Set-SPEnterpriseSearchServiceApplication -DatabaseName "<NewDbName>" -DatabaseServer "<NewServerName>" 

 

Where:

  1.  
    1.  
      •  
        • <NewDbName> is the name of the renamed database
      •  
        • <NewServerName> is the new database location
  2. Monitor whether the search instances have finished re-provisioning.
Do {write-host -NoNewline .;Sleep 10; $searchInstance = Get-SPEnterpriseSearchServiceInstance -Local} while ($searchInstance.Status -ne "Online")

 

Additional References:

  1. Rename FAST Search for SharePoint 2010 Databases
  2. Rename or  Move Service Application
  3. Change database (FAST Search Server 2010 for SharePoint)


Sub reports are great for showing data from a related table. This works just like a sub form, by setting the master/child linking fields.

What else can you use a sub report to print?

Other data that is not related to a specfic reord in the parent report. The trick is to not set the master/child linking fields. This allows you to print information in the report header or footer that is not "link" to a record.

Sub reports are great for sunmmizing the data in a report.

By basing an sub report's recprd source on the same record source as the parent report, you can show all the totals for each grouping (hiding the detail). You can also create a  totaling query based on the parent report's record source (query)

What if you want to place the report's total in the report header?

Use a sub report that cauclates and displays just the total.   

How do you print several different statistics that are caclulated with different queries?

Use sub reports. It is possible to have a parent report that has no record source, only sub reports.

How to print a header on each page when a sub report spans multiple pages?

Becuse page headers do not print from a sub report you have to use group header. This is done by creating a grouping that will group all record into a single group. You then can set teh group header to repeat.

1. Open the subreport in design view.
2. Open the Sorting and Grouping box.
3. In the Field column of the dialog, enter an expression that won't change, e.g.: =0 and set Group Header to Yes.
4. Right-click the new group header (grey bar on the report), and choose Properties. Set Repeat Section to Yes.

This gives you a group header that appears at the top of the subreport. It will repeat on each new page like the way you would excect the page header for the subreport.

Working with Report Header and Footer sections.

Print order for4 sections:

  • Pager Header - Prints at the top of each page.  This section can NOT be set to grow or shrink. The Page Header prints before the Report Header/Footer. It is possible to turn off the Page Header so it does not print with the Report Header/Footer
  • Report Header - prints once at the beginning. This section can be set to grow or shrink.
  • Group Headers - prints at the begining of each group This section can be set to grow or shrink. It can also be set to Repeat on each new page.
  • Group Footers - prints at the end of each group. This section can be set to grow or shrink.
  • Report Footer - prints once at the end. This section can be set to grow or shrink.
  • Page Footer - prints at the bottom of each page. This section can NOT be set to grow or shrink. The Page Feader prints after the Report Header/Footer. It is possible to turn off the Page Footer so it does not print with the Report Header/Footer

When a report is used as a Sub Report, the header and footer sections work a little different.

Print order for sections:

  • Pager Header - does NOT print. The parent report is responsible for the page header
  • Report Header - prints once at the beginning. This section can be set to grow or shrink.
  • Group Headers - prints at the begining of each group This section can grow or shrink. It can also be set to Repeat on each new page.
  • Group Footers - prints at the end of each group. This section can be set to grow or shrink.
  • Report Footer - pirnts once at the end. This section can be set to grow or shrink.
  • Page Footer - does NOT print. The Parent report is responsible for the page footer.

How to create something lke a  a Page Header in a Sub Report

You can create a dummy header .grouping by setting the group on to  1 (enter the digit 1). You can then set the section to repeat. Now you have a  group header that will print on every page.

Header and Footer Tips

Repeating Group Headers:

In the Group Header's prperties, set the Repeat property to Yes to get the header to print on every page if the group spans multiple pages.

Print Report Header without a Page Header/Footer:

In the Report's properties, set the Page Header property to Not With Rpt Hdr or Not With Rpt Hdr/Ftr depending on your needs.

Print Report Footer without a Page Footer/Footer:

In the Report's properties, set the Page Footer property to Not With Rpt Ftr or Not With Rpt Hdr/Ftr depending on your needs.



Nov
19

Run As Administrator

by Dave Stuart | Tags:

Everything you need to know about Run as Administrator: http://www.sevenforums.com/tutorials/11841-run-administrator.html

 



I ran into a problem recently when looking up the Created By and Modified By fields for an List Item so I caould display it on an Application Page. When I opened the page it worked fine, however when a user with less privilages opened it they got an error laie this "Value does not fall within the expected range".

This is what I found and I have no idea why this was the solution BUT it worked for me.

http://blog.vanmeeuwen-online.nl/2012/07/value-does-not-fall-within-expected.html

Solution(s):
It seems there can be several causes.
1). Use of invalid field name. You need to use the internal field name! However, that was not the case in my situation.
2). Change the List View Lookup Threshold value of the web application. Default value is 8, I changed it to 20 and big surprise: it worked! Thanks to this post.
Note: My item has some lookup fields some of which some have more than 8 items.
Little conclusion: So it seems that when using (one of) the system admin accounts, this list view lookup threshold is ignored in one way. By using non-system admin accounts, it can be a show stopper.
Steps to edit this value:

  • Go to Central Administration > Application Management > Manage web applications
  • Select the appropriate web application (in my case the SharePoint - 80)
  • In the ribbon bar, select General Settings > Resourse Throttling
  • Search for the List View Lookup Threshold and change the value to 20.


This is a very good article about Working with VBA in the 32-bit and 64-bit Versions of Office 2010 http://msdn.microsoft.com/en-us/library/ff700513(v=office.11).aspx

I have re-posted it and referenced it here! Mainly for my own reference :-)

Office 2010 32-bit and 64-bit Client Installations


Microsoft offers a 32-bit client installation and 64-bit client installation of Microsoft Office 2010. If you use a 64-bit version of Microsoft Windows, you can choose which version of Microsoft Office to use. By using the 64-bit version, you can experience improved application performance by using more physical memory for storage and by moving more data in fewer operations.

However, there are considerations when moving your 32-bit applications to or creating solutions for the 64-bit version of Microsoft Office. For example, applications written for the 64-bit version likely do not work in previous versions of Microsoft Office. Also, calls to Microsoft Windows Application Programming Interface (API) functions from your application code may not work.

Calls to 64-bit Windows API functions from 32-bit solutions (and the opposite) may lead to erratic behavior or system crashes resulting from the truncation of data or overflows into protected memory spaces. To compensate for this, Microsoft Office provides a 32-bit version and 64-bit version of several of the Declare statements used in the Windows API. To ensure compatibility, you must change the Declare statements in solutions to differentiate between 32-bit calls and 64-bit calls. These differences and remedies are described in the article Compatibility Between the 32-bit and 64-bit Versions of Office 2010.

Office 2010 introduces a new version of Microsoft Visual Basic for Applications (VBA) known as VBA 7.0 that is updated to work with 64-bit client installations. VBA 7.0 improves the performance of your Microsoft Office applications through 64-bit performance improvements. VBA 7.0 also enables you to create applications that are compatible with Office 2007 or continue to use VBA solutions created in previous versions. To improve compatibility of application code targeted to a particular version of Microsoft Office, there is a compilation constant (VBA7) that enables you to determine the version of VBA you are using and execute the correct code. Note that if your applications are only written for the 32-bit versions of Microsoft Office, no changes are necessary to your code.

There is also a compilation constant (Win64) that enables your Office 2010 solutions to work with both the 32-bit version and 64-bit version. Both of these compilation constants are demonstrated in the following sections.

As stated previously, VBA 7.0 works with 64-bit versions of Microsoft Office. To enable VBA solutions created for 32-bit versions to continue working in Office 2010, the compilation constant (VBA7) tests to determine the VBA version used in the solution.

The following code example shows how to use the VBA7 constant. This example enables you to find the location and size of the main window in Microsoft Excel 2010. To do this, first, a user-defined type, RECT, is created. Next, the Windows API functions, FindWindow and GetWindowRect, are defined to return the dimensions of the window. Because there is a 32-bit version and 64-bit version of these functions, the VBA7 compilation constant directs the compiler to the correct section of code. Then, the DisplayExcelWindowSize subroutine is called. This subroutine calls the FindWindow and GetWindowRect functions. Finally, a message box appears with the dimensions.

' A user-defined type to store the window dimensions.
Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

' Test which version of VBA you are using.
#If VBA7 Then
   ' API function to locate a window.
   Declare PtrSafe Function FindWindow Lib "user32" _
      Alias "FindWindowA" ( _
      ByVal lpClassName As String, _
      ByVal lpWindowName As String) As LongPtr
    
   ' API function to retrieve a window's dimensions.
   Declare PtrSafe Function GetWindowRect Lib "user32" ( _
      ByVal hwnd As LongPtr, _
      lpRect As RECT) As Long

#Else
   ' API function to locate a window.
   Declare Function FindWindow Lib "user32" _
      Alias "FindWindowA" ( _
      ByVal lpClassName As String, _
      ByVal lpWindowName As String) As Long
    
   ' API function to retrieve a window's dimensions.
   Declare Function GetWindowRect Lib "user32" ( _
      ByVal hwnd As Long, _
      lpRect As RECT) As Long
#End If

Sub DisplayExcelWindowSize()
   Dim hwnd As Long, uRect As RECT
   
   ' Get the handle identifier of the main Excel window.
   hwnd = FindWindow("XLMAIN", Application.Caption)
   
   ' Get the window's dimensions into the RECT UDT.
   GetWindowRect hwnd, uRect
   
   ' Display the result.
   MsgBox "The Excel window has these dimensions:" & _
      vbCrLf & " Left: " & uRect.Left & _
      vbCrLf & " Right: " & uRect.Right & _
      vbCrLf & " Top: " & uRect.Top & _
      vbCrLf & " Bottom: " & uRect.Bottom & _
      vbCrLf & " Width: " & (uRect.Right - uRect.Left) & _
      vbCrLf & " Height: " & (uRect.Bottom - uRect.Top)
   
End Sub

To test this solution, add a module to Excel 2010, insert the previous code, and then run the macro. You should see a message displayed similar to Figure 1 with the dimensions, in pixels, of the window.

Figure 1. Message with the dimensions of the main Excel window

Message with the Excel window dimensions

Resize the Excel window and rerun the macro. You should see that the values changed.

In some solutions, you must provide code for the 32-bit version of Office 2010 and code for the 64-bit version of Office 2010. And as in the previous example, you must call different versions of the Windows API functions. To do this, the Win64 compilation constant is available as shown in the following example.

' Test whether you are using the 64-bit version of Office 2010.
#If Win64 Then
   Declare PtrSafe Function GetTickCount64 Lib "kernel32" () As LongLong
#Else
   Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long
#End If

In this example, if you code is running in the 64-bit version of , the GetTickCount64 function is called. Otherwise, the GetTickCount function is called.

VBA 7.0 is the latest version of VBA that improves the performance of applications that are created in Office 2010. To enable you to continue using your legacy solutions in different versions of Microsoft Office, the VBA7 compilation constant is available. Likewise, because there is now a 32-bit version and 64-bit version of Office 2010, you use the Win64 compilation constant to direct the compiler to the run the correct section of code in your VBA applications.



So you are getting ###### in your report!

The Currency format adds "White Spaces" to the right (and left I think).  So changing the format from Currency to $#,##0.00 for decimal place fields and $#,##0 for no decimal places gives to more room. You can also set the Left and Right padding to ZERO.  The advantage with the new format is that it removes "White Spaces" to the right that are automatically added when using the Currency format.

Enjoy

Dave



Nov
02

NoWrap in ASP.Net

by Dave Stuart | Tags:

If you want your table column to not wrap in ASP.Net, you can use the NoWrap property in the tag like so:

  1. <td nowrap="nowrap">  
  2.  content  
  3. </td>  

This makes the code xhtml compliant and prevents warnings in the source view of designer in Visual Studio. Normally you could just specify a nowrap attribute by itself in plain html.

Or the CSS equivalent of setting nowrap:

  1. <td style="white-space:nowrap;">  
  2.  content  
  3. </td>  

Again, using the first option will prevent warnings in source view.



I recently needed to change the Title of an Application Page in SharePoint 2010 from code behind. This is how I did it in Page_Load...

So the sequence goes:

  1. Get a reference to the appropriate Content Placeholder
  2. Clear out anything that SharePoint might have put in it already
  3. Put your content in.

Or, in C#:

ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder) Page.Master.FindControl("PlaceHolderPageTitle");

contentPlaceHolder.Controls.Clear();

LiteralControl literalControl = new LiteralControl();

literalControl.Text = "Your text goes here";

contentPlaceHolder.Controls.Add(literalControl);



Reference: http://support.microsoft.com/kb/209207

The following table lists the Microsoft Access command-line options.

   Option       Effect                                    Applies to
   -----------------------------------------------------------------
   database     Opens the specified Microsoft Access      Access 
                database or Microsoft Access project.     database or 
                Include a path if necessary. If you are   Access 
                running Windows 95, the default path is   project
                your My Documents folder.	
                            
   /excl        Opens the specified Access database for   Access 
                exclusive access. To open the database    database 
                for shared access in a multiuser          only
                environment, omit this option. 
	
   /ro          Opens the specified Access database or    Access 
                Access project for read-only access.      database or 
                                                          Access 
                                                          project

   /user        Starts Access using the specified user    Access 
   user name    name.                                     database 
                                                          only

   /pwd         Starts Access using the specified         Access 
   password     password.                                 database 
                                                          only

   /profile     Starts Access using the options in the    Access 
   user         specified user profile instead of the     database or 
   profile      standard Microsoft Windows registry       Access 
                settings created when you installed       project
                Access. This replaces the /ini option  	
                used in versions of Access earlier   	
                than Access 97 to specify an   	
                initialization file.

   /compact     Compacts and repairs the Access           Access 
   target       database, or compacts the Access project, database or 
   database or  specified before the /compact option and  Access 
   target       then closes Access. If you omit a target  project
   Access       file name following the /compact option, 	
   project      the file is compacted to the original  	
                name and folder. To compact to a different  
                name, specify a target file. If you don't 	
                include a path in target database or target 	
                Access project, the target file is created  	
                in your My Documents folder by default. In 	
                an Access project, this option compacts 	
                the Access project (.adp) file but not the 	
                SQL Server database. 
	
   /repair      Repairs the Access database specified     Access 
                before the /repair option and then        database 
                closesAccess. In Access 2000, compact     only
                and repair functionality is combined  	
                under /compact. The /repair option is 	
                supported for backward compatibility. 
	
   /convert     Converts an Access database in an         Access 
   target       earlier version to an Access 2000         database 
   database     database with a new name and then closes  only
                Access. Specify the source database  	
                before using the /convert option. 	

   /x  macro    Starts Access and runs the specified      Access 
                macro. Another way to run a macro when    database or 
                you open a database is to use an          Access 
                AutoExec macro.                           project
                             
   /cmd         Specifies that what follows on the        Access 
                command line is the value that will be    database or 
                returned by the Command function. This    Access 
                option must be the last option on the     project
                command line. You can use a semicolon (;)	
                as an alternative to /cmd. 	

   /nostartup   Starts Access without displaying the      Access 
                startup dialog box (the second dialog     database or 
                box that you see when you start Access).  Access 
                                                          project

   /wrkgrp      Starts Access using the specified         Access 
   workgroup    workgroup information file.               database 
   information                                            only
   file

   /runtime     Starts Access in run-time mode.           Accesss 
                                                          database or 
                                                          Access 
                                                          project

Notes

 

  • To run a Visual Basic for Applications procedure when you open a database, use the RunCode action in the AutoExec macro or in the macro that you run by using the command-line option /x. You can also run a Visual Basic procedure when you open a database by creating a form with a Visual Basic procedure defined for its OnOpen event. Designate this form as the startup form by right-clicking the Database window, clicking Startup, and then entering that form in the Display Form/Page box.
  • To specify a forward slash (/) or semicolon (;) on the command line, type the character twice. For example, to specify the password ;mjs/md on the command line, type ;;mjs//md following the /pwd command-line option.
  • Examples:

    You can type the following command in the Run dialog box to open an Access 2000 database in exclusive mode that runs the specified macro at the startup:
    "C:\Program Files\Microsoft Office\Office\msaccess.exe" "C:\Program Files\Microsoft Office\Office\samples\northwind.mdb" /Excl /X Add Products
    To open an Access 2002 database in exclusive mode that runs the specified macro at the startup, type the following command in the Run dialog box:
    "C:\Program Files\Microsoft Office\Office10\msaccess.exe" "C:\Program Files\Microsoft Office\Office10\samples\northwind.mdb" /Excl /X Add Products
    Similarly, if you want to open an Access 2003 database in exclusive mode that runs the specified macro at the startup, type the following command in the Run dialog box:
    "C:\Program Files\Microsoft Office\Office11\msaccess.exe" "C:\Program Files\Microsoft Office\Office11\samples\northwind.mdb" /Excl /X Add Products


The Blogger

Dave Stuart I'm a Developer with a passion for coding. I enjoy the challengers that come with the job! SharePoint is one of my expert areas along with .NET Web Development with MVC and good old MS Access VBA coding. I Blog so that I can remember how I did that way back when; PLUS all this stuff is searchable! I constantly study and run my own business, Dafran Inc. I have passed 22 Microsoft Exams since 1998 when I first jumped on the treadmill of knowledge. I hope that you enjoy this Blog as much as I enjoy updating it. All the very best from Calgary, Alberta, Canada. contact me at linkedin @ dafran.ca

Calendar

<<  November 2017  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Sign in