Archive

Archive for the ‘LightSwitch’ Category

LightSwitch: Hide Export to Excel Button


To hide the Export to Excel button follow these steps:

Open the screen

In the screen designer, select the Data Grid whose excel button to be hidden

Open property window or press F4

Check Disable Export to Excel

 

Launch the application

Categories: LightSwitch, Tips Tags: ,

Lightswitch: Hide Grid’s Search Textbox


In some cases, we need to hide the search textbox on top of the grid.

 

To hide the textbox following these steps:

Open the screen that contains the grid

Select the query for the grid whose search textbox need to be hidden

Open Property Window (or hit F4)

Uncheck Support Search

Run the application

Categories: LightSwitch, Tips Tags: ,

LightSwitch: Oracle An error occurred while starting a transaction on the provider connection. See the inner exception for details


I got this issue today while connecting to the Oracle database. I am not taking credit of the solution but I couldn’t find a post that explains it step by step. For the benefit of the community I decided to write this post. It is also good for me to find the solution later on if I get stuck J

To fix the issue we need to create a transaction scope and call TransactionScope.complete when the execution is complete

Right click the oracle Datasource

Select View Code

Add the following code to the generated class; replace OracleDSService with the name of your class

using System.Transactions;

namespace LightSwitchApplication
{

    public partial class OracleDSService
    {
        private TransactionScope transactionScope;
        partial void SaveChanges_Executing()
        {
            transactionScope = new TransactionScope(TransactionScopeOption.Required,
                        new TransactionOptions() { IsolationLevel = IsolationLevel.ReadCommitted });
        }

        partial void SaveChanges_Executed()
        {
            transactionScope.Complete();
        }
    }
}

In my case System.Transactions namespace wasn’t resolved. To fix that I had to add a reference to the System.Transactions assembly

To do so, follow these steps

Switch to the File View

Right click on the server project and choose Add Reference

Find the System.Transactions assembly; in my case it was at C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Transactions.dll

Save the solution, build, and run

Categories: LightSwitch Tags:

LightSwitch: Change Default Database Instance


I posted How to Change Development Database in LightSwitch which shows how to change the database at the project level. But if you are really bored repeating the process every single time you create a new project and you want to change the default instance of you database, you can follow these steps:

  • Close Visual Studio (IMPORTANT!)
  • Open the Windows Registry i.e. Regedit
  • I am using Visual Studio Ultimate: Go to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\DataProject
  • Change the value for the DefaultSSEName key with the database instance you want to use. For instance I replace SQLExpress with SQLExpress2k8R2
  • Close Regedit
  • Open Visual Studio
  • Create new Lightswitch project
  • Unload project then right click and select edit project
  • Check SqlExpressInstanceName
Categories: LightSwitch Tags:

How to Change Development Database in LightSwitch

September 27, 2011 3 comments

Last week I had an issue building my LightSwitch project on Windows 8 instance because it had SQL 11 express instance as the default DB instance on the computer. I then installed SQL Server 2008 R2 Express on the machine to make it build.

You may have noticed that LightSwitch doesn’t provide an intuitive way to change the instance of the Dev database. I have done the following to connect to the SQL Server 2008 R2 instance

Right click on the LS project

Unload project

Right click the project and click edit

Find SqlExpressInstanceName attribute

Replace the database instance with one you want to connect to. In my case, I replaced

<SqlExpressInstanceName>SQLEXPRESS</SqlExpressInstanceName>

With

<SqlExpressInstanceName>SQLEXPRESS2k8</SqlExpressInstanceName>

Right click the project and reload

Categories: LightSwitch Tags: