Category Archives: LOB – Lập trình – Phát triển phần mềm

KHÓA ĐÀO TẠO: XÂY DỰNG HỆ THỐNG THỰC HÀNH LABS BIZTALK


Virtual Labs BizTalk

I.            Giới thiệu về khóa học

1.   Mục đích:

–          Hiện nay trên thị trường hầu hết các doanh nghiệp, Trường đại học, cao đẳng hoặc phổ thông, các Tổ chức khai thác sử dùng hệ thống quản lý CNTT hầu hết là không tập trung, không có kiến trúc nền tảng về hệ thống PaaS hoặc VDI hoặc không có giải pháp sâu tới người dùng thực tế.

–          Chi phí dịch vụ, đào tạo thường xuyên cao và phải tái đầu tư liên tục.

–          Để chủ động hơn trong việc kiểm soát, cũng như phát triển hệ thống quản lý hạ tầng công nghệ, tạo điều kiện tốt cho sự phát triển của tổ chức. Chúng tôi đưa ra các khoá đào tạo tư vấn giải pháp xây dựng hệ thống thực hành LABs cho nhiều mô hình tổ chức khác nhau.

–          Một trong những nội dung đào tạo của chúng tôi đó là: “Xây dựng hệ thống thực hành LAB BIZTALK”.

2.   Nội dung:

Đến với khóa học các bạn được học và thực hành cách cấu hình, cài đặt, xây dựng, vận hành một hệ thống LAB BIZTALK trên môi trường ảo hóa của VMware.

Khóa học hướng đến đào tạo cho các học viên những kiến thức tổng quát và xuyên xuốt các vấn đề:

  1. Cách thức, quy trình xây dựng giải pháp.
  2. Hệ thống mạng ảo (vNIC).
  3. Hệ thống máy chủ ảo (VMs).
  4. Thiết kế thành phần vApp.

II.         Đối tượng tham gia

–          Quản trị CNTT của Tổ chức, Công ty, Doanh nghiệp đang quản lý một môi trường nhiều máy chủ: có nhu cầu học thiết lập hệ thống bizTalk cho tổ chức của mình, có kỹ năng về tích hợp hệ thống nội bộ, bên ngoài và các đối tác thương mại để phát triển các ứng dụng xử lý kinh doanh có sử dụng BizTalk Server 2010, 2013.

–          Lãnh đạo CNTT: quan tâm tới các giải pháp xử lý thông tin liên hoàn, truy xuất nguồn gốc dữ liệu, xử lý quy trình chuỗi dữ liệu trong tổ chức kinh doanh như: siêu thị, smart chain, giám sát thông tin giữa nhiều khâu tổ chức, giữa các doanh nghiệp liên kết khác nhau…

–          Kỹ sư hệ thống: những người đang thiết kế và quản lý một cơ sở hạ tầng doanh nghiệp tư nhân, tổ chức, nhà nước.

III.       Yêu cầu với học viên

  1. Có kiến thức cơ bản về Hệ điều hành Windows / Linux, hệ thống mạng (Network).
  2. Kiến thức cơ bản về hệ thống ảo hóa vSphere của VMware, Virtual Box, Hyper-V.
  3. Ưu tiên các bạn có kiến thức về hệ thống Active Directory, SSO, ADFS, Domain Controller, CSDL SQL Server, Quản trị BizTalk.

 

IV.      Lợi ích của việc tham gia khóa học:

  1. Học viên có thể chủ động xây dựng hệ thống thực hành LAB BizTalk: Hệ thống Demo để người quản trị và người lập trình BizTalk biết được cách cấu hình hệ thống và hướng phát triển ứng dụng nhóm.
  2. Được đào tạo vững chắc kiến thức nền tảng hệ thống Lab, trên đó có thể tiến hành cài đặt, cấu hình, triển khai, giám sát và quản lý môi trường BizTalk. Thực hành trên nhiều máy chủ có cài đặt BizTalk, phát triển các ứng dụng tích hợp, đăng nhập 1 lần, tích hợp các sản phẩm thương mại.
  3. Có công cụ, môi trường thực nghiệm sẵn sang để giám sát chất lượng sản phẩm phần mềm, chăm sóc dịch vụ ứng dụng của khách hàng qua các giai đoạn phát triển phiên bản khác nhau.

Cách tạo dự án Sharepoint bằng VS2010 không cần cài SharePoint


 

Nếu ta tạo 1 dự án SharePoint bằng VS2010 mà không cài SharePoint 2010 thì sẽ nhận được các lỗi sau:

A SharePoint server is not installed on this computer. A SharePoint server must be installed to work with SharePoint Projects

Thông thường  Microsoft khuyên nên cài SharePoint nên các máy Development.

Having SharePoint installed is required. It won’t let you create a new project unless its present. I remote debug a lot when MOSS 2007, but with all of the benefits in Visual Studio 2010, it is worth developing directly on the SharePoint server.

Nhưng như vậy, có rất nhiều nhu cầu xuất hiện như: chúng tôi phải làm nhóm với nhau. tiết kiệm máy chủ SharePoint, máy laptop không thể đủ tài nguyên cho việc vừa lập trình vừa cho chạy SharePoint Server …

Đây là các bước xây dựng dự án SharePoint  bằng Visual Studio 2010

 

Create, build, and deploy your code

  1. Build a SP2010 virtual machine
  2. Install VS2010 on the host machine
  3. Export the hive [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0] (see attached registry file) from the virtual machine and install on the local machine
  4. Create a webpart project in VS2010, build, and package.
  5. Copy the wsp to the virtual machine and the pdb.
  6. Deploy the wsp via Add-SPSolution.
  7. Go to Run … enter c:\windows\assembly\gac_msil, find your assembly, copy the pdb to the same folder as the assembly.

Get the debugger running on the virtual machine

  1. Copy Remote Debugger to SP2010 virtual machine .. found on host at: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger
  2. Create identical debug user accounts on both the host and guest machines and add to local administrator group on both machines (not sure if admin group is necessary).
  3. On the virtual machine, start the msvsmon.exe, in the x64 folder using this command: C:\Windows\System32\runas.exe /user:<your debug user account> /netonly “C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe”
  4. On the virtual machine msvsmon, enter the password of the debug user account.
  5. On the virtual machine msvsmon, go to Tools->Permissions, and grant the debug user account permission to debug.

Attach to the process on the virtual machine from VS2010

  1. Refresh the page your webpart resides on to get the w3wp process going.
  2. On the virtual machine determine the process id of the w3wp instance your code is executing. Not sure if IISApp.vbs is on Server 2008 R2, but this link provides a PS script to get the process id.
  3. On the virtual machine, make a note of the name of the msvsmon instance … mine is CORP\administrator@<server name>.
  4. In VS2010, Attach to Process, and enter the name of the msvsmon instance in the Qualifier field of the window.
  5. Look for the instances of w3wp, and attach to the process id your code is executing in.
  6. Now the obvious step … set a breakpoint in your code, then refresh your page.

Note: 4 & 5 are where most of the issues, if you have any, will take place. If you are unable to see a list of processes running, or even attach to the remote debugger, something is wrong with your debug accounts. Note the id and pwd must be identical on both the host and guest. I have them both in the admin group. Also, be sure your running the x64 debugger.

 

1. Build a SP2010 virtual machine

2. Install VS2010 on the host machine

3. Export the hive [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0] from the virtual machine and install on the local machine

4. Create a webpart project in VS2010, build, and package.

I still can’t create sharepoint project after importing the registry keys.

What i tried is to create exactly same folder (in my local machine)

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI

import all the DLL from SP Server to my local machine. and it works!!!

Sưu tầm: Getting Started with SQL Azure Development


Trích bài viết của Lynn Langit is a developer evangelist for Microsoft in Southern California. She’s published two books on SQL Server Business Intelligence and has created a set of courseware to introduce children to programming at TeachingKidsProgramming.org. Read her blog at blogs.msdn.com/b/SoCalDevGal.

Bài viết này cũng có trong bài thi cơ đấy.

Microsoft Windows Azure offers several choices for data storage. These include Windows Azure storage and SQL Azure. You may choose to use one or both in your particular project. Windows Azure storage currently contains three types of storage structures: tables, queues and blobs.

SQL Azure is a relational data storage service in the cloud. Some of the benefits of this offering are the ability to use a familiar relational development model that includes much of the standard SQL Server language (T-SQL), tools and utilities. Of course, working with well-understood relational structures in the cloud, such as tables, views and stored procedures, also results in increased developer productivity when working in this new platform. Other benefits include a reduced need for physical database-administration tasks to perform server setup, maintenance and security, as well as built-in support for reliability, high availability and scalability.

I won’t cover Windows Azure storage or make a comparison between the two storage modes here. You can read more about these storage options in Julie Lerman’s July 2010 Data Points column (msdn.microsoft.com/magazine/ff796231). It’s important to note that Windows Azure tables are not relational tables. The focus of this is on understanding the capabilities included in SQL Azure.

This article will explain the differences between SQL Server and SQL Azure. You need to understand the differences in detail so that you can appropriately leverage your current knowledge of SQL Server as you work on projects that use SQL Azure as a data source.

If you’re new to cloud computing you’ll want to do some background reading on Windows Azure before continuing with this article. A good place to start is the MSDN Developer Cloud Center at msdn.microsoft.com/ff380142.

Getting Started with SQL Azure

To start working with SQL Azure, you’ll first need to set up an account. If you’re an MSDN subscriber, then you can use up to three SQL Azure databases (maximum size 1GB each) for up to 16 months (details at msdn.microsoft.com/subscriptions/ee461076) as a developer sandbox. To sign up for a regular SQL Azure account (storage and data transfer fees apply) go to microsoft.com/windowsazure/offers/.

After you’ve signed up for your SQL Azure account, the simplest way to initially access it is via the Web portal at sql.azure.com. You must sign in with the Windows Live ID that you’ve associated to your Windows Azure account. After you sign in, you can create your server installation and get started developing your application.

An example of the SQL Azure Web management portal is shown in Figure 1. Here you can see a server and its associated databases. You’ll notice that there’s also a tab on the Web portal for managing the Firewall Settings for your particular SQL Azure installation.

image: Summary Information for a SQL Azure Database

Figure 1 Summary Information for a SQL Azure Database

As you initially create your SQL Azure server installation, it will be assigned a random string for the server name. You’ll generally also set the administrator username, password, geographic server location and firewall rules at the time of server creation. You can select the location for your SQL Azure installation at the time of server creation. You will be presented with a list of locations (datacenters) from which to choose. If your application front end is built in Windows Azure, you have the option to locate both that installation and your SQL Azure installation in the same geographic location by associating the two installations.

By default there’s no access to your server, so you’ll have to create firewall rules for all client IPs. SQL Azure uses port 1433, so make sure that port is open for your client application as well. When connecting to SQL Azure you’ll use the username@servernameformat for your username. SQL Azure supports SQL Server Authentication only; Windows Authentication is not supported. Multiple Active Result Set (MARS) connections are supported.

Open connections will time out after 30 minutes of inactivity. Also, connections can be dropped for long-running queries and transactions or excessive resource usage. Development best practices in your applications around connections are to open, use and then close those connections manually, to include retry connection logic for dropped connections and to avoid caching connections because of these behaviors. For more details about supported client protocols for SQL Azure, see Steve Hale’s blog post at blogs.msdn.com/b/sqlnativeclient/archive/2010/02/12/using-sql-server-client-apis-with-sql-azure-vversion-1-0.aspx.

Another best practice is to encrypt your connection string to prevent man-in-the-middle attacks.

You’ll be connected to the master database by default if you don’t specify a database name in the connection string. In SQL Azure the T-SQL statement USE is not supported for changing databases, so you’ll generally specify the database you want to connect to in the connection string (assuming you want to connect to a database other than master). Here’s an example of an ADO.NET connection:

  1. Server=tcp:server.ctp.database.windows.net;
  2. Database=<databasename>;
  3. User ID=user@server;
  4. Password=password;
  5. Trusted_Connection=False;
  6. Encrypt=true;

Setting up Databases

After you’ve successfully connected to your installation you’ll want to create one or more databases. Although you can create databases using the SQL Azure portal, you may prefer to do so using some of the other tools, such as SQL Server Management Studio 2008 R2. By default, you can create up to 149 databases for each SQL Azure server installation. If you need more databases than that, you must call the Windows Azure business desk to have this limit increased.

When creating a database you must select the maximum size. The current options for sizing (and billing) are Web or Business Edition. Web Edition, the default, supports databases of 1GB or 5GB total. Business Edition supports databases of up to 50GB, sized in increments of 10GB—in other words, 10GB, 20GB, 30GB, 40GB and 50GB.

You set the size limit for your database when you create it by using the MAXSIZE keyword. You can change the size limit or the edition (Web or Business) after the initial creation using the ALTER DATABASE statement. If you reach your size or capacity limit for the edition you’ve selected, then you’ll see the error code 40544. The database size measurement doesn’t include the master database, or any database logs. For more details about sizing and pricing, see microsoft.com/windowsazure/pricing/#sql.

It’s important to realize that when you create a new SQL Azure database, you’re actually creating three replicas of that database. This is done to ensure high availability. These replicas are completely transparent to you. The new database appears as a single unit for your purposes.

Once you’ve created a database, you can quickly get the connection string information for it by selecting the database in the list on the portal and then clicking the Connection Strings button. You can also quickly test connectivity via the portal by clicking the Test Connectivity button for the selected database. For this test to succeed you must enable the Allow Microsoft Services to Connect to this Server option on the Firewall Rules tab of the SQL Azure portal.

Creating Your Application

After you’ve set up your account, created your server, created at least one database and set a firewall rule so that you can connect to the database, you can start developing your application using this data source.

Unlike Windows Azure data storage options such as tables, queues or blobs, when you’re using SQL Azure as a data source for your project, there’s nothing to install in your development environment. If you’re using Visual Studio 2010, you can just get started—no additional SDKs, tools or anything else are needed.

Although many developers will choose to use a Windows Azure front end with a SQL Azure back end, this configuration is not required. You can use any front-end client with a supported connection library such as ADO.NET or ODBC. This could include, for example, an application written in Java or PHP. Connecting to SQL Azure via OLE DB is currently not supported.

If you’re using Visual Studio 2010 to develop your application, you can take advantage of the included ability to view or create many types of objects in your selected SQL Azure database installation directly from the Visual Studio Server Explorer. These objects are Tables, Views, Stored Procedures, Functions and Synonyms. You can also see the data associated with these objects using this viewer. For many developers, using Visual Studio 2010 as the primary tool to view and manage SQL Azure data will be sufficient. The Server Explorer View window is shown in Figure 2. Both a local installation of a database and a cloud-based instance are shown. You’ll see that the tree nodes differ slightly in the two views. For example, there’s no Assemblies node in the cloud installation because custom assemblies are not supported in SQL Azure.

image: Viewing Data Connections in Visual Studio Server Explorer

Figure 2 Viewing Data Connections in Visual Studio Server Explorer

As I mentioned earlier, another tool you may want to use to work with SQL Azure is SQL Server Management Studio (SSMS) 2008 R2. With SSMS 2008 R2, you actually have access to a fuller set of operations for SQL Azure databases than in Visual Studio 2010. I find that I use both tools, depending on which operation I’m trying to complete. An example of an operation available in SSMS 2008 R2 (and not in Visual Studio 2010) is creating a new database using a T-SQL script. Another example is the ability to easily perform index operations (create, maintain, delete and so on). An example is shown in Figure 3.

image: Using SQL Server Management Studio 2008 R2 to Manage SQL Azure

Figure 3 Using SQL Server Management Studio 2008 R2 to Manage SQL Azure

Newly released in SQL Server 2008 R2 is a data-tier application, or DAC. DAC pacs are objects that combine SQL Server or SQL Azure database schemas and objects into a single entity. You can use either Visual Studio 2010 (to build) or SQL Server 2008 R2 SSMS (to extract) to create a DAC from an existing database.

If you wish to use Visual Studio 2010 to work with a DAC, then you’d start by selecting the SQL Server Data-Tier Application project type in Visual Studio 2010. Then, on the Solution Explorer, right-click your project name and click Import Data-Tier Application. A wizard opens to guide you through the import process. If you’re using SSMS, start by right-clicking on the database you want to use in the Object Explorer, click Tasks, then click Extract Data-Tier Application to create the DAC.

The generated DAC is a compressed file that contains multiple T-SQL and XML files. You can work with the contents by right-clicking the .dacpac file and then clicking Unpack. SQL Azure supports deleting, deploying, extracting and registering DAC pacs, but does not support upgrading them.

Another tool you can use to connect to SQL Azure is the latest community technology preview (CTP) release of the tool code-named “Houston.” Houston is a zero-install, Silverlight-based management tool for SQL Azure installations. When you connect to a SQL Azure installation using Houston, you specify the datacenter location (as of this writing North Central U.S., South Central U.S., North Europe, Central Europe, Asia Pacific or Southeast Asia).

Houston is in early beta and the current release (shown in Figure 4) looks somewhat like SSMS. Houston supports working with Tables, Views, Queries and Stored Procedures in a SQL Azure database installation. You can access Houston from the SQL Azure Labs site at sqlazurelabs.com/houston.aspx.

image: Using Houston to Manage SQL Azure

Figure 4 Using Houston to Manage SQL Azure

Another tool you can use to connect to a SQL Azure database is SQLCMD (msdn.microsoft.com/library/ee336280). Even though SQLCMD is supported, the OSQL command-line tool is not supported by SQL Azure.

Using SQL Azure

So now you’ve connected to your SQL Azure installation and have created a new, empty database. What exactly can you do with SQL Azure? Specifically, you may be wondering what the limits are on creating objects. And after those objects have been created, how do you populate those objects with data?

As I mentioned at the beginning of this article, SQL Azure provides relational cloud data storage, but it does have some subtle feature differences to an on-premises SQL Server installation. Starting with object creation, let’s look at some of the key differences between the two.

You can create the most commonly used objects in your SQL Azure database using familiar methods. The most commonly used relational objects (which include tables, views, stored procedures, indices and functions) are all available. There are some differences around object creation, though. Here’s a summary of those differences:

  • SQL Azure tables must contain a clustered index. Non-clustered indices can be subsequently created on selected tables. You can create spatial indices, but you cannot create XML indices.
  • Heap tables are not supported.
  • CLR geo-spatial types (such as Geography and Geometry) are supported, as is the HierachyID data type. Other CLR types are not supported.
  • View creation must be the first statement in a batch. Also, view (or stored procedure) creation with encryption is not supported.
  • Functions can be scalar, inline or multi-statement table-valued functions, but cannot be any type of CLR function.

There’s a complete reference of partially supported T-SQL statements for SQL Azure on MSDN at msdn.microsoft.com/library/ee336267.

Before you get started creating your objects, remember that you’ll connect to the master database if you don’t specify a different one in your connection string. In SQL Azure, the USE (database) statement is not supported for changing databases, so if you need to connect to a database other than the master database, then you must explicitly specify that database in your connection string, as shown earlier.

Data Migration and Loading

If you plan to create SQL Azure objects using an existing, on-premises database as your source data and structures, then you can simply use SSMS to script an appropriate DDL to create those objects on SQL Azure. Use the Generate Scripts Wizard and set the “Script for the database engine type” option to “for SQL Azure.”

An even easier way to generate a script is to use the SQL Azure Migration Wizard, available as a download from CodePlex at sqlazuremw.codeplex.com. With this handy tool you can generate a script to create the objects and can also load the data via bulk copy using bcp.exe.

You could also design a SQL Server Integration Services (SSIS) package to extract and run a DDM or DDL script. If you’re using SSIS, you’d most commonly design a package that extracts the DDL from the source database, scripts that DDL for SQL Azure and then executes that script on one or more SQL Azure installations. You might also choose to load the associated data as part of the package’s execution path. For more information about working with SSIS, see msdn.microsoft.com/library/ms141026.

Also of note regarding DDL creation and data migration is the CTP release of SQL Azure Data Sync Services (sqlazurelabs.com). You can see this service in action in a Channel 9 video, “Using SQL Azure Data Sync Service to provide Geo-Replication of SQL Azure Databases,” at tinyurl.com/2we4d6q. Currently, SQL Azure Data Sync services works via Synchronization Groups (HUB and MEMBER servers) and then via scheduled synchronization at the level of individual tables in the databases selected for synchronization.

You can use the Microsoft Sync Framework Power Pack for SQL Azure to synchronize data between a data source and a SQL Azure installation. As of this writing, this tool is in CTP release and is available from tinyurl.com/2ecjwku. If you use this framework to perform subsequent or ongoing data synchronization for your application, you may also wish to download the associated SDK.

What if your source database is larger than the maximum size for the SQL Azure database installation? This could be greater than the absolute maximum of 50GB for the Business Edition or some smaller limit based on the other program options.

Currently, customers must partition (or shard) their data manually if their database size exceeds the program limits. Microsoft has announced that it will be providing an auto-partitioning utility for SQL Azure in the future. In the meantime, it’s important to note that T-SQL table partitioning is not supported in SQL Azure. There’s a free utility called Enzo SQL Shard (enzosqlshard.codeplex.com) that you can use for partitioning your data source.

You’ll want to take note of some other differences between SQL Server and SQL Azure regarding data loading and data access.

Added recently is the ability to copy a SQL Azure database via the Database copy command. The syntax for a cross-server copy is as follows:

  1. CREATE DATABASE DB2A AS COPY OF Server1.DB1A

The T-SQL INSERT statement is supported (with the exceptions of updating with views or providing a locking hint inside of an INSERT statement).

Related further to data migration, T-SQL DROP DATABASE and other DDL commands have additional limits when executed against a SQL Azure installation. In addition, the T-SQL RESTORE and ATTACH DATABASE commands are not supported. Finally, the T-SQL statement EXECUTE AS (login) is not supported.

Data Access and Programmability

Now let’s take a look at common programming concerns when working with cloud data. First, you’ll want to consider where to set up your development environment. If you’re an MSDN subscriber and can work with a database that’s less than 1GB, then it may well make sense to 
develop using only a cloud installation (sandbox). In this way there will be no issue with migration from local to cloud. Using a regular (non-MSDN subscriber) SQL Azure account, you could develop directly against your cloud instance (most probably using a cloud-located copy of your production database). Of course, developing directly from the cloud is not practical for all situations.

If you choose to work with an on-premises SQL Server database as your development data source, then you must develop a mechanism for synchronizing your local installation with the cloud installation. You could do that using any of the methods discussed earlier, and tools like Data Sync Services and Sync Framework are being developed with this scenario in mind.

As long as you use only the supported features, the method for having your application switch from an on-premises SQL Server installation to a SQL Azure database is simple—you need only to change the connection string in your application.

Regardless of whether you set up your development installation locally or in the cloud, you’ll need to understand some programmability differences between SQL Server and SQL Azure. I’ve already covered the T-SQL and connection string differences. In addition, all tables must have a clustered index at minimum (heap tables are not supported).

As previously mentioned, the USE statement for changing databases isn’t supported. This also means that there’s no support for distributed (cross-database) transactions or queries, and linked servers are not supported.

Other options not available when working with a SQL Azure database include:

  • Full-text indexing
  • CLR custom types (however, the built-in Geometry and Geography CLR types are supported)
  • RowGUIDs (use the uniqueidentifier type with the NEWID function instead)
  • XML column indices
  • Filestream datatype
  • Sparse columns

Default collation is always used for the database. To make collation adjustments, set the column-level collation to the desired value using the T-SQL COLLATE statement.

And finally, you cannot currently use SQL Profiler or the Database Tuning Wizard on your SQL Azure database.

Some important tools that you can use with SQL Azure for tuning and monitoring include:

  • SSMS Query Optimizer to view estimated or actual query execution plan details and client statistics
  • Select Dynamic Management views to monitor health and status
  • Entity Framework to connect to SQL Azure after the initial model and mapping files have been created by connecting to a local copy of your SQL Azure database.

Depending on what type of application you’re developing, you may be using SSAS, SSRS, SSIS or PowerPivot. You can also use any of these products as consumers of SQL Azure database data. Simply connect to your SQL Azure server and selected database using the methods already described in this article.

It’s also important to fully understand the behavior of transactions in SQL Azure. As mentioned, only local (within the same database) transactions are supported. In addition, the only transaction-isolation level available for a database hosted on SQL Azure is READ COMMITTED SNAPSHOT. Using this isolation level, readers get the latest consistent version of data that was available when the statement STARTED.

SQL Azure doesn’t detect update conflicts. This is also called an optimistic concurrency model, because lost updates, non-repeatable reads and phantoms can occur. Of course, dirty reads cannot occur.

Database Administration

Generally, when using SQL Azure, the administrator role becomes one of logical installation management. Physical management is handled by the platform. From a practical standpoint this means there are no physical servers to buy, install, patch, maintain or secure. There’s no ability to physically place files, logs, tempdb and so on in specific physical locations. Because of this, there’s no support for the T-SQL commands USE <database>, FILEGROUP, BACKUP, RESTORE or SNAPSHOT.

There’s no support for the SQL Agent on SQL Azure. Also, there is no ability (or need) to configure replication, log shipping, database mirroring or clustering. If you need to maintain a local, synchronized copy of SQL Azure schemas and data, then you can use any of the tools discussed earlier for data migration and synchronization—they work both ways. You can also use the DATABASE COPY command.

Other than keeping data synchronized, what are some other tasks that administrators may need to perform on a SQL Azure installation?

Most commonly, there will still be a need to perform logical administration. This includes tasks related to security and performance management. Additionally, you may be involved in monitoring for capacity usage and associated costs. To help you with these tasks, SQL Azure provides a public Status History dashboard that shows current service status and recent history (an example of history is shown in Figure 5) at microsoft.com/windowsazure/support/status/servicedashboard.aspx.

image: SQL Azure Status History

Figure 5 SQL Azure Status History

SQL Azure provides a high-security bar by default. It forces SSL encryption with all permitted (via firewall rules) client connections. Server-level logins and database-level users and roles are also secured. There are no server-level roles in SQL Azure. Encrypting the connection string is a best practice. Also, you may want to use Windows Azure certificates for additional security. For more details, see blogs.msdn.com/b/sqlazure/archive/2010/09/07/10058942.aspx.

In the area of performance, SQL Azure includes features such as automatically killing long-running transactions and idle connections (more than 30 minutes). Although you can’t use SQL Profiler or trace flags for performance tuning, you can use SQL Query Optimizer to view query execution plans and client statistics. You can also perform statistics management and index tuning using the standard T-SQL methods.

There’s a select list of dynamic management views (covering database, execution or transaction information) available for database administration as well. These include sys.dm_exec_connections , _requests, _sessions, _tran_database_transactions, _active_transactions and _partition_stats. For a complete list of supported dynamic management views for SQL Azure, see msdn.microsoft.com/library/ee336238.aspx#dmv.

There are also some new views such as sys.database_usage and sys.bandwidth_usage. These show the number, type and size of the databases and the bandwidth usage for each database so that administrators can understand SQL Azure billing. A sample is shown in Figure 6. In this view, quantity is listed in KB. You can monitor space used via this command:

  1. SELECT SUM(reserved_page_count) * 8192
  2. FROM sys.dm_db_partition_stats

image: Bandwidth Usage in SQL Query

Figure 6 Bandwidth Usage in SQL Query

You can also access the current charges for the SQL Azure installation via the SQL Azure portal by clicking on the Billing link at the top-right corner of the screen.

Learn More

To learn more about SQL Azure, I suggest you download the Windows Azure Training Kit. This includes SQL Azure hands-on learning, white papers, videos and more. The training kit is available from microsoft.com/downloads/details.aspx?FamilyID=413E88F8-5966-4A83-B309-53B7B77EDF78.

Also, you’ll want to read the SQL Azure Team Blog at blogs.msdn.com/b/sqlazure/ and check out the MSDN SQL Azure Developer Center at msdn.microsoft.com/windowsazure/sqlazure.

If you want to continue to preview upcoming features for SQL Azure, be sure to visit SQL Azure Labs at sqlazurelabs.com.

Sưu tầm: Các phương thức bổ sung giao diện cho các ứng dụng làm từ LightSwitch 2011


This walkthrough demonstrates how to create a theme extension for Visual Studio LightSwitch. A theme extension defines a color and font palette for the LightSwitch shell.

To create a theme extension, you must do the following:

  1. Create a theme extension project.

  2. Specify the display name and description.

  3. Define the theme.

  4. Test the theme extension.

Prerequisites


  • Visual Studio Professional 2012

  • Visual Studio 2012 SDK

  • LightSwitch Extensibility Toolkit for Microsoft Visual Studio 2012

Create a Theme Extension Project


The first step is to create a project and add a LightSwitch Theme template.

To create an extension project
  1. On the menu bar in Visual Studio, choose File, New Project.

  2. In the New Project dialog box, select the LightSwitch node, and then select LightSwitch Extension Library (Visual Basic) or LightSwitch Extension Library (C#).

  3. In the Name field, type TestThemeExtension as the name for your extension library. This name will appear on the Extensions tab of the LightSwitch Application Designer.

  4. Choose the OK button to create a solution that contains the seven projects that are required for the extension.

To choose an extension type
  1. In Solution Explorer, select the TestThemeExtension.Lspkg project.

  2. On the menu bar, choose Project, Add New Item.

  3. In the Add New Item dialog box, select LightSwitch Theme.

  4. In the Name field, enter TestTheme as the name for your extension.

  5. Choose the OK button. Files will be added to several projects in your solution.

Specify the Display Name and Description


The default name for your theme is “TestTheme” and the default description is “TestTheme description.” Both of these will appear in the Application Designer at design time. Therefore, you will change them to something more meaningful.

To specify the display name and description
  1. In Solution Explorer, choose the TestThemeExtension.Common project.

  2. Expand the Metadata and Themes nodes, and open the TestTheme.lsml file.

  3. In the Theme element, replace the DisplayName value with Test Theme, and replace the Description value with This is my first try at creating a theme. As follows.

    Xml

    Copy

    <Theme Name="TestTheme">
        <Theme.Attributes>
          <DisplayName Value="Test Theme"/> 
          <Description Value="This is my first try at creating a theme."/>
        </Theme.Attributes>
      </Theme>
    

    These are the values that developers will see when they select your theme on the General Properties tab of the application designer.

At this point you have created a theme, and you can test it in a LightSwitch application.

Define the Theme


The LightSwitch Theme project template added a TestTheme.xaml file to the TestThemeExtension.Client project. This file contains the resource directory for the LightSwitch shell; the default values and styles define the appearance of the LightSwitch Blue Theme (Default) theme that is the default for LightSwitch applications. You define your own theme by modifying some or all of the values in this file. For more information on the available styles, see Control Elements for LightSwitch Themes.

To define the theme
  1. In Solution Explorer, choose the TestThemeExtension.Client project.

  2. Expand the Presentation and Themes nodes, and open the TestTheme.xaml file.

  3. On the menu bar, choose Edit, Find and Replace, Quick Replace.

  4. In the Find and Replace dialog box, enter Segoe UI, Arial in the Find what field, and enter Segoe Script in the Replace with field.

  5. Choose Current Document in the Look in list, and then choose Replace All.

    Eleven occurrences will be replaced, defining Segoe Script for all of the font values.

  6. In the TestTheme.xaml file, locate the TextBoxBackgroundBrush element, and replace <SolidColorBrush x:Key=”TextBoxBackgroundBrush” Color=”White”/> with <SolidColorBrush x:Key=”TextBoxBackgroundBrush” Color=”Yellow”/>.

  7. Locate the ToolbarBackgroundBrush element and replace <SolidColorBrush x:Key=”ToolbarBackgroundBrush” Color=”#FFE9EDF1″/ with <SolidColorBrush x:Key=”ToolbarBackgroundBrush” Color=”Red”/.

    Note that the color values can be entered as either a System.Drawing.Color value or a hexadecimal color value.

    TipTip

    You can also open the .xaml file in Microsoft Expression Blend 4 and change the colors in a visual designer.

At this point you have created a rudimentary theme, and you can test it in a LightSwitch application.

Test the Theme Extension


You can test the theme extension in an experimental instance of Visual Studio. If you have not already tested another LightSwitch extensibility project, you have to enable the experimental instance first.

To enable an experimental instance
  1. In Solution Explorer, select the TestThemeExtension.Vsix project.

  2. On the menu bar, choose Project, TestThemeExtension.Vsix Properties.

  3. On the Debug tab, under Start Action, choose Start external program.

  4. Enter the path of the Visual Studio executable, devenv.exe.

    By default on a 32-bit system, the path is C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe; on a 64-bit system, it is C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe.

  5. In the Command line arguments field, type /rootsuffix Exp as the command-line argument.

    NoteNote

    All subsequent LightSwitch extensibility projects will also use this setting, by default.

To test the theme
  1. On the menu bar, choose Debug, Start Debugging. An experimental instance of Visual Studio opens.

  2. In the experimental instance, on the menu bar, choose File, Open Project.

  3. In the Open Project dialog box, select any existing LightSwitch application project and open it.

  4. On the menu bar, choose Project, ProjectName Properties.

  5. In the project designer, on the Extensions tab, check the TestThemeExtension check box.

  6. Select the General Properties tab, and in the Theme list, choose Test Theme.

  7. On the menu bar, choose Debug, Start Debugging. Observe the changes in appearance in the running application.

Next Steps


This completes the theme extension walkthrough; you should now have a fully functioning theme extension that you can reuse in any LightSwitch project. Of course, you might want to modify the styles to make the theme a bit more pleasing to the eye; the walkthrough is only intended to show you the necessary techniques.

If you are going to distribute your extension, there are a couple more steps that you must take. To make sure that the information displayed for your extension in the project designer and in Extension Manager are correct, update the properties for the VSIX package. For more information, see How to: Set VSIX Package Properties. In addition, there are several things to consider if you are going to distribute your extension publicly. For more information, see How to: Distribute a LightSwitch Extension.

 

LightSwitch Metro Theme Extension Sample

Introduction

This sample demonstrates how to recreate the LightSwitch Metro Theme extension, a contemporary theme for Visual Studio LightSwitch applications.

Building the Sample

The prerequisites for this sample are:

In addition to these prerequisites, you should be proficient in either Visual Basic or C# and should be familiar with theming in Silverlight. We also recommend that you be familiar with creating Visual Studio extensions using the Visual Studio SDK.

Description

This sample expands upon the Help topic Walkthrough: Creating a Theme Extension, which demonstrates a simple theme that defines fonts and colors. The Metro theme also makes use of styles, defining new appearance and behavior for the built-in LightSwitch control templates. To provide a consistent experience, you will need to define Resource Dictionaries in the form of a .xaml file for each control template, as shown in the following illustration:

Additional styles are defined in the MetroStyles.xaml file, which also contains a MergedDictionaries node that references the other .xaml files. When LightSwitch loads the extension, it reads in all of the style information and applies it to the built-in templates, providing a different look and feel for your application.

There isn’t much code in this sample; most of the work is done in xaml. You can use this sample as a starting point for your own theme, changing the fonts, colors, and styles to create your own look. Enjoy!

More Information

For more information on creating extensions for Visual Studio LightSwitch, seeVisual Studio LightSwitch 2011 Extensibility Toolkit.

 

LightSwitch Extensibility Toolkit for Visual Studio 2012

Visual Studio LightSwitch is a tool for developing business applications for the desktop, web, and cloud. You can extend the functionality of LightSwitch by creating extensions using Microsoft Visual Studio Professional 2012, the Visual Studio 2012 SDK, and the LightSwitch Extensibility Toolkit for Microsoft Visual Studio 2012.

The following are required in order to create LightSwitch extensions:

  • Visual Studio Professional 2012

  • Visual Studio 2012 SDK

  • LightSwitch Extensibility Toolkit for Microsoft Visual Studio 2012

In addition to these prerequisites, you should be proficient in either Visual Basic or C# and should be familiar with both Windows Presentation Foundation (WPF) and Silverlight. We also recommend that you be familiar with creating Visual Studio extensions using the Visual Studio SDK.

Extension Types


There are six types of extensions for LightSwitch:

  • Business types

    Let you wrap a base data type in a semantic type, providing additional validation and display capabilities in LightSwitch while continuing to store the data in its underlying type. They can include a Silverlight control for displaying data.

  • Custom controls

    Silverlight user controls with additional attributes to make them usable in and better integrated with LightSwitch.

  • Data sources

    Domain service adapter class that enables LightSwitch to work with other data sources.

  • Screen templates

    Can be used to create screens that have common layout patterns different from the standard screen layouts provided by LightSwitch.

  • Shells

    Let you create an application shell with a different layout and different capabilities than the standard LightSwitch application shell.

  • Themes

    Let you create a different appearance and behavior for LightSwitch applications and controls.

The LightSwitch Extensibility Toolkit for Microsoft Visual Studio 2012 includes templates that contain the necessary files for each extension type.

Creating LightSwitch Extension Projects


The LightSwitch Extensibility Toolkit for Microsoft Visual Studio 2012 installs two new project templates, LightSwitch Extension Library (Visual Basic) and LightSwitch Extension Library (Visual C#), that can be used to create extensions. When you select one of these project types, a solution with seven projects is generated:

  • The projects with names that end in .Client, .Client.Design, .Common, .Design, and .Server contain the various parts of the extension items that will be added to the library.

    Content ​project

    Purpose​

    Referenced by​

    Client

    Contains client implementations that should be deployed with a LightSwitch application but are not found in the Common project. For example, controls, shells, and themes.

    Client sub-project

    Client.Design

    Contains implementations necessary during the debugging of a LightSwitch application. For example, control images or custom property editors for the runtime screen designer.

    Client sub-project

    Common

    Contains ​implementations that are common to both the client and the server. For example, metadata loaders and validators.

    Client sub-project, server sub-project, Visual Studio IDE

    Design

    Contains implementations for design time integrated development environment (IDE) operations. For example, a screen template.

    Visual Studio IDE

    Server

    Contains server implementations that should be deployed with a LightSwitch application but are not found in the Common project. For example, data sources.​

    Server sub-project

  • The .Lspkg project packages the previous five projects so that LightSwitch can unpack and reference them when the package is installed.

  • The .Vsix project packages the generated .Lspkg file into a .Vsix package so that it can be added to LightSwitch through the Extension Manager.

The contents of each project will differ depending on which extension type template is selected. To learn more about how to create extensibility projects, see How to: Create a LightSwitch Extension Project

Developing LightSwitch Extensions


The process of developing a LightSwitch extension is like that of developing a Visual Studio extension using the Visual Studio SDK. As with any extension, you create an extensibility project, write code for the extension, debug the extension, set properties for the .Vsix package, and distribute the extension.

The actual code that you have to write will vary depending on the extension type. To start working with a particular extension type, see one of the following topics:

As with any Visual Studio extension, you debug a LightSwitch extension by using an experimental instance of Visual Studio. To learn more about how to debug, see How to: Debug or Test a LightSwitch Extension.

Once your extension is complete, you will want to set properties in the .Vsix package to identify the extension. For more information, see How to: Set VSIX Package Properties. The final step is to publish your extension on Visual Studio Gallery. For more information, see How to: Distribute a LightSwitch Extension.

Sưu tầm: Creating A LightSwitch Theme Extension using Expression Blend


image

Visual Studio LightSwitch allows you to create Theme extensions. A theme controls the overall look of a LightSwitch application.

image

Microsoft has an article, Walkthrough: Creating a Theme Extension, that covers the basics of creating themes for LightSwitch, however, this article will go a bit deeper and demonstrate creating more complex themes.

First note that the following are required in order to create LightSwitch extensions:

image

First, we create an extension project in Visual Studio.

image

We add a New Item to the .Lspkg project.

image

We add a Theme to the project.

image

A number of files are created in the various projects in the solution, including files in the Theme folder in the .Client project.

image

We click on the .Vsix project…

image

We then Start Debugging. This will open another instance of Visual Studio.

image

We create or open a LightSwitch project and go into Properties.

image

We click on the Extensions tab and enable the theme extension.

image

On the General Properties tab we select the Theme.

image

We then run the application.

image

The application shows with the default theme.

We now close the application, and the Visual Studio instance, and return to the extensions project.

Creating a Basic Theme

image

We right-click on the .xaml file and open it in Expression Blend.

image

When we click on the Resources tab, we can easily alter the brush styles.

image

When we run the application we see that our changes are reflected.

A More Advanced Theme

image

If we look at the LightSwitch Metro Theme we see an example of a more advanced theme.

image

It contains a class that implements the IThemeExtension interface, and an associated resource file.

See Jan Van der Haegen‘s article: Adding control styles to your LightSwitch theme extension for a full explanation of the the IThemeExtension interface.

image

We add a new class that implements the IThemeExtension interface using the following code:

using System;
using System.ComponentModel.Composition;
using Microsoft.LightSwitch.Theming;
using System.Collections.Generic;
using Microsoft.LightSwitch.Model;

namespace SimpleGreenTheme.Presentation.Themes
{
    [Export(typeof(IThemeExtension))]
    [Theme(GreenTheme.ThemeId, GreenTheme.ThemeVersion)]
    internal class MetroStyles :
        IThemeExtension
    {
        IEnumerable<Uri> IThemeExtension.GetControlStyleResources(
            string themeId, string themeVersion, IEnumerable<IModuleDefinition> modules)
        {
            yield return new
                Uri(@"/SimpleGreenTheme.Client;component/Presentation/Themes/GreenStyles.xaml", 
                UriKind.Relative);
        }
    }
}

image

Next, we add a Resource Dictionary to the project.

image

We can download Silverlight Themes from this link to “grab some ideas” Smile.

image

When we open the resource file in Expression Blend

image

We can visually edit the theme.

image

When we run the application we are able to see our advanced theming of controls.

Download Code

The LightSwitch project is available at http://lightswitchhelpwebsite.com/Downloads.aspx

Sưu tầm: công cụ chuyển đổi Media content vào SharePoint 2010


Express yourself! Share your work with other members of the Expression Community.

Each contribution is licensed to you under a License Agreement by its owner, not Microsoft. Microsoft does not guarantee the contribution or purport to grant rights to it.

    Close

    Expression Encoder 4 SharePoint 2010 plugin

    Description

    The SharePoint plugin for Expression Encoder 4 will allow you to publish your encoded output to the SharePoint 2010 video gallery.

    To install:

    1. Close down all instances of Expression Encoder 4
    2. Install the SharePoint Foundation 2010 Client Object Model Redistributable
    3. Unzip package to your desktop
    4. Copy the SharePointPublishPlugin.dll to \Microsoft Expression\Encoder 4\Plugins directory. You may have to provide administrator credentials to copy file to your Program Files directory.
    5. Launch Expression Encoder
    6. On the Output tab, open the Publish To drop down on the Publish panel and select Windows Azure Blob Storage.
    7. Enter your account name and access key to authenticate your credentials.

    NOTE: At this time, IIS Smooth Streaming content uploaded to SharePoint cannot be played back directly from the service.

    Bài viết hay về vấn đề kinh doanh Công nghệ thông tin thời khủng hoảng


    Five reasons business process improvement projects fail

    By Scott Lowe

    August 22, 2012, 5:20 AM PDT

    Takeaway: Even with the best of intentions, even the most sought after business process improvement project can fail. Here are five reasons this happens and some advice for CIOs that want to avoid such failure.

    Many CIOs have found or are looking for opportunities to elevate their departments to “business enabler” or “business multiplier” status, with all the rights and privileges therein. These rights and privileges often include increased respect from business partners and, even if the IT budget doesn’t fully escape the axe, a better understanding for the potential impact of such cuts.

    Many of these efforts take the form of business process improvement initiatives designed to improve the efficiency of existing work, which could mean having that work take either less time, less money or both. In many organizations, CIOs and the IT department are well positioned to take the lead on such efforts.

    Unfortunately, even with the best of intentions, even the most sought after business process improvement project can fail. Here, I will outline five reasons that these efforts often fail and provide some advice for CIOs that want to avoid such failure and see their projects succeed.

    Lack of support from the top

    Regardless of organizational size, attempting to initiate a significant process improvement effort without clear, direct and publicized support from the top will more than likely result in either total failure of the initiative or the eventual outcomes not being everything that they could be.

    Lack of support from the top can be perceived by staff as the initiative not being important and not being deserving of the full time and effort that is required to ensure success. Business process improvement projects can be difficult, so reinforcement from the top that the efforts are necessary and appreciated is critical to the team’s success.

    Mitigation: Get clear, public support for the overall initiative before starting any work. Get real support, too, not just words. Ensure that the leadership team is truly ready and that they won’t simply back down when the going gets tough.

    Organizational culture

    I’ve been in organizations in which the culture itself made process improvement efforts extremely difficult. In short, for pretty much any task, individual employees were empowered to simply opt out or refuse to take part. Given the process improvement efforts have the potential to sometimes uncover individual weakness or group challenges, it’s not a surprise that there may be some angst when improvement efforts are undertaken.

    In one organization, I was stunned to discover the kinds of items that people could simply refuse to do, seemingly without repercussion. In that environment, the process improvement efforts were extraordinarily challenging and required much more dedication and time from the project leadership team than I’ve seen in other efforts.

    In another example, for a substantial process improvement effort, a VP had promised access to certain members of her team for a period of months with a verbal promise that no other significant objectives would be put before those people until our efforts were complete. As you may have guessed, that promise did not hold and the team was pulled in too many different directions, resulting in failure since no one would budge on the due dates for any initiative.

    Mitigation: In these environments, take a slow, measured approach to the initiative and make certain that leadership is squarely on board before proceeding. Ensure that the importance of the project trickles throughout the organization. Consider tying awards or some kind of compensation to outcomes to ensure reasonable participation. Further, get all commitments in writing along with fallback dates that are automatic in certain conditions, such as when a team member falls ill or when a promise is not kept.

    Non-cooperative team members

    In some cases, organizational culture is to blame for the failure of some efforts and for the shortcomings of some members of the team. However, when the organization itself is sound, you may have a team member that is either hostile or less than engaged in the overall effort. Because the team is theoretically comprised of those with a stake in the process being discussed, everyone needs to be fully involved in order to get the best results.

    Mitigation: Find out what’s behind the hostility. If your organization starts the process improvement efforts with the hope that some people can be downsized as a result, don’t expect a lot of cooperation from the individuals whose jobs may be at stake. Further, if you’ve decided to undertake a BPI project to correct a personnel situation rather than dealing with the personnel situation directly, expect failure.

    Project team is not representative

    If you want to see what failure truly looks like, attempt to reengineer a process without ensuring that all of those with a stake in the process are represented during the effort. Perhaps the most important task is selecting the team that will work on the project. All stakeholders, from start to finish, need to be represented. Even if a person has just a small part in a large process, the insights and experience from each individual part of the process must be understood in order to improve it.

    Mitigation: Easy! Be inclusive, even if you’re inclusive to a fault.

    Initiative is too IT-focused

    Although CIOs may be well suited to lead process improvement efforts, the outcomes may not be about technology at all. Bear in mind that IT plays a supporting role in a company’s process efforts; it’s not all about IT. What is important is leveraging technology assets in ways that optimize a company’s efforts. If the process discussion is slanted to a point where it looks like IT is taking over the process, you will end up with one of two scenarios: 1) Failure or 2) IT being saddled with “responsibility” for everything that happens in the organization. Neither is desirable.

    Mitigation: CIOs need to wear their business hats when leading process improvement efforts.

    Cách sửa lỗi khi lập trình bằng Visual Studio Lightswitch 2011


    Trong quá trình lập trình và debug Build Project chúng ta rất thường hay gặp các lỗi sau:

    1. If a user has installed SharePoint 2010 on a Windows 7 machine the default SQLExpress Instance is “SharePoint” which doesn’t connect to the default instance of SQLExpress needed by LightSwitch
    —————————————-
    An error occurred while establishing a connection to SQL Server instance ‘.\.\SharePoint’.
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.

    2. Cannot connect to PC-NAME\SQLEXPRESS. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476

    3. I cannot run any LightSwitch program

    I downloaded and installed LigthSwitch hopping to start beta testing immediately. Unfortunatelly, it cannot access the SQLExpress database instance, and I could not figure-out what is wrong.

    Các bước sửa lỗi như sau:

    Bước 1.

    Changing the option in Options ==> Database Tools==>Data Connections will apply to the new projects that you create.

    Try looking for the .lsproj file for you project on the file system. If you open this file in notepad, you’ll see a SQLEPXRESSINSTANCENAME element which will be set to SQLEXPRESS. Correcting this setting may fix your problem.

    Bước 2.

    Deleting all files in the dir ‘%LOCALAPPDATA%\Microsoft\Microsoft SQL Server Data\SQLEXPRESS’ solved the problem.

    Bước 3.

    Please check the ServerName which you provided. It should match with the below shown Name in the UserName textbox, and that name should followed with \SQLEXPRESS:

    Connect dialog

    Bước 4.

    I know this question is old, but in case it helps anyone make sure the SQL Server Browser is running in the Services MSC. I installed SQL Server Express 2008 R2 and the SQL Server Browser Service was set to Disabled.

    1. Start->Run->Services.msc
    2. Find “SQL Server Browser”->Right Click->Properties
    3. Set Startup Type to Automatic->Click Apply
    4. Retry your connection.

    Khởi động cùng dòng sản phẩm lập trình LOB “Dòng sản phẩm ứng dụng cho Doanh nghiệp” của Visual Studio LightSwitch 2010


    You might know that LightSwitch is now in Beta 2 stage. Microsoft released it few days ago. I have a series of Tutorials on LightSwitch Beta 1 where we discussed on creating database tables using the LightSwitch table designer.

    In this tutorial, we will discuss how to attach an existing database table available in your SQL server database. This was also available in Beta 1 release. This time, we will discuss with the latest version. Read the full post and at the end, leave your feedback.

    If you are new to LightSwitch, you may like to read my previous chapters too. You can find them here: “Beginners Guide to Visual Studio LightSwitch“. I appreciate your feedback.

    Setting up Environment

    To start with, we need Visual Studio LightSwitch. Currently it is in Beta 2 stage, which you can download from Microsoft download site. Click the below image to download the installer:

    Make sure that, you already have Visual Studio 2010 SP1 installed in your machine. If you don’t have SP1, you can also download it from here:

    Once your development machine is ready with LightSwitch Beta 2, open Visual Studio 2010 and create a new LightSwitch project as shown below:

    image

    Once you hit “OK”, it will take some time to generate the project.

    Quick Look into Existing Table

    Let us create a new table called “EmployeeTable” in our SQL Server database. You can use your existing table too. If you don’t have SQL Server installed in your PC, you can use the SQLExpress also for working with that.

    Here is our table definition which we will use to attach to our LightSwitch application:

    image

    In our table, we have “EmpID” as the Primary key, some strings and one date field. You can see the definition in the above screenshot.

    Connecting External DataSource

    Now once you have your table ready, it is the time to connect to it from your application. To do this, in the Visual Studio IDE home page, you will find one option called “Attach to external Data Source” (as shown below):

    image

    Click the link to open the connection Wizard. Alternatively, you can right click on the “Data Sources” folder inside your solution Explorer (as shown below) and from the context menu, click “Add Data Source…”. This will also do the same trick from you.

    image

    Ok, let us click the link from the Home Page (if you are unable to find it, you can open it from View -> Home Page). Have a look at it here:

    image

    Let’s click on the link in the Home Page to continue attaching on the external data source.

    image

    This will open up the “Attach Data Source Wizard” dialog in the screen.

    image

    From the above screen, chose “Database” and click “Next”. This will open another dialog called “Connection Properties” for you. In this dialog, you will be able to configure your database connection settings.

    image

    Select the “Server name”, “Authentication information” and “Database name” from the dialog. Click “Test Connection” to check whether the connection established. On success, click “OK” to continue.

    image

    Now, it will start retrieving your database tables for you and show them in the screen.

    image

    Select the appropriate table that you want to connect from the above dialog and give your proper name to the DataSource name. For this tutorial, we will use our existing table named “EmployeeTable“. Click “Finish” to attach the table with your solution.

    Once you click “Finish”, it will import the table information and show it up on the screen (as shown below):

    image

    Here you will see that it kept the proper Data Type that we have in our original table. That’s all about attaching an existing table in LightSwitch application.

    image

    Now open the Solution Explorer. You will see that it actually created the Data Source named “employeeData“, and in that data source we have the table called “EmployeeTable“. Hey, all this without writing a single piece of code, as you can see.

    Bắt đầu với LOB (Line of Biz) và Visual Studio LightSwitch 2010


    Beginners Guide to Visual Studio LightSwitch

    By Kunal Chowdhury

     

    Introduction

    Visual Studio LightSwitch is a new tool for building data-driven Silverlight Application using Visual Studio IDE. It automatically generates the User Interface for a DataSource without writing any code. You can write a small amount of code also to meet your requirement. Recently, I got some time to explore Visual Studio LightSwitch. I created a small DB application with proper data inserting UI within a small amount of time (without any XAML or C# code). Here in this article, I will guide you to understand it with the help of a small application. There will be a series of articles on this topic regularly. Read the complete article to learn about creating a Silverlight data driven application with the help of Visual Studio LightSwitch.

    Setting up LightSwitch Environment

    Microsoft Visual Studio LightSwitch Beta 1 is a flexible, business application development tool that allows developers of all skill levels to quickly build and deploy professional-quality desktop and Web business applications. To start with LightSwitch application development, you need to install the Visual Studio LightSwitch in your development machine. To do so, follow the below steps:

    • Install Visual Studio 2010
    • Install Visual Studio LightSwitch

    The LightSwitch installation will install all other components to your PC one by one including SQL Express, Silverlight 4, LightSwitch Beta server, etc. You can download the LightSwitch Beta 1 from here: Microsoft Download Center (Visual Studio LightSwitch Beta 1).

    Creating a LightSwitch Project

    Once you installed Visual Studio LightSwitch, run the Product to create a new project. Go to File –> New –> Project or press Ctrl + Shift + N to open the “New Project”. From the left panel, select “LightSwitch”. In the right pane, it will filter the LightSwitch project templates. This will include of type VB & C#. Select your respective type. Here I will use the C# version.

    image

    In the above dialog Window, enter the name of the project, select proper location for the project to create and hit “Ok”. This will create the blank LightSwitch project for you by the Visual Studio 2010 IDE. It will take some time for the project creation. So, be patient.

    Create a Database Table

    After the project has been created by the IDE, it will open up the following screen:

    image

    You can see that, it has two options in the UI. You can create a new table for your application. Also, you can attach an external database. If you open the Solution Explorer, you will see that, the project is totally empty. It has only two folders named “Data Sources” and “Screens”. “Data Sources” stores your application data, i.e. Database Tables. On the other side, the “Screens” folder stores the UI screens created by you. I will describe them later in this tutorial. Let’s create a new Table for our application. Click on the “Create new table” to continue. This will bring up the following screen on your desktop:

    image

    In the above page, you can design your Table structure as you do in the SQL server while creating a new table. Each table will have a “Id” assigned to the table of type “Int32” & it is a Primary Key to the table. Add some additional columns to the table.

    image

    In the above snapshot, you can see that, there are several column types (data types) available in LightSwitch application. For our sample application, we will create 4 additional columns called “FirstName (String)”, “LastName (String)”, “Age (Int16)” and “Marks (Decimal)”. Change the title of the table from “Table1Item” to “StudentTable”. This name will be used while saving the table. Save the table now. If you want to change the name of the table later, just rename the table header and save it. This will automatically update the table name.

    image

    Be sure to set all the fields as “Required” field. This will be helpful validating the data. I will show it to you later.

    Create a Data Entry Screen

    Once you are done with structuring your database table columns, you will need to create a UI screen for your application to insert records. Click on the “Screen…” button from the top panel as shown in the below snapshot:

    image

    This will open the “Add New Screen” dialog window to the screen. Select “New Data Screen” from the Screen Template, provide a Screen Name in the right panel & choose the database table as Screen Data from the dropdown.

    image

    Click “Ok” to continue. This will create a new UI screen for your application to insert new data record by end user. Now, in the solution explorer you can see that, the “Data Sources” folder has one database named “ApplicationData” and it has a table called “StudentTables”. In the “Screens” folder, you can find the recently created data entry screen named “CreateNewStudentTable”. You can change the design of the UI from the below screen:

    image

    You can add or delete new fields or controls. You can also rearrange the controls in the UI. For our first sample application, we will go with the default layout controls.

    See the Application in Action

    Woo!!! Our application is ready. We will be able to insert new records in our database table from our application. No need to write a single line of code. What? You are not agreeing with me! Let’s run the application by pressing F5. This will build your solution. It will take some time to compile the solution. Once it builds successfully, it will open the following UI in your desktop:

    image

    It is a Silverlight OOB Application. If you want to confirm, right click on the application & you will see the Silverlight context menu pops up in the screen. OMG!!! We didn’t do anything to design the above UI! The Visual Studio LightSwitch automatically created the screen for you with a “Save” and “Refresh” button. You can see a collapsible “Menu” panel at the left of the screen. In the right side, you will see tabular panel containing some labels and TextBox which will be required to insert data in your application database. In the top right corner of the screen, you will see a “Customize Screen” button. Once you click this, it will pop up another Child Window for you to customize the application screen at runtime. This will not be visible, once you deploy the application. We will cover them later in different article.

    Validation of Fields

    As I told you earlier, our application is ready. So, what to do for writing some simple validation for our application? Wait, you don’t have to worry about that. LightSwitch internally does that for you. Let’s have a demo on it. In the form panel, insert some data. We will purposefully write invalid data in the “Age” field. Instead of entering age, we will enter some text in the age field. If you press tab or click elsewhere (on lost focus), it will do the validation & show the error on the screen.

    image

    You can see the validation error popup in the screen as shown here:

    image

    Now enter proper values for all of the fields and click “Save”. This will save the records properly.

    More on Save

    Once you entered proper values in the input boxes, click “Save” to store the record.

    image

    This will save the record and add another field called “Id” in the UI. The value for the Id will be 1 (one) as this was our first record & will increase by 1 as we add more records.

    image

    To add more records, close the current tab and click “CreateNewStudentTable” menu item from the left panel.

    image

    Now enter some records and click Save button. You will see it in action that, the Id is automatically increasing by 1 as and when you are saving a new record.

    image

    If you have any unsaved records and want to close the tab or want to add a new record, it will open a message dialog to the screen warning about unsaved changes. It will ask you to save the changes before proceeding.

    image

    Click “Save” to save the unsaved record to database. Click “Discard” if you don’t want to save the record. Click “Cancel” to stay on the same page.

    Customize the Screen

    If you want to change the UI at runtime, click on the “Customize Screen” button available at the top right corner of the application window. Remember, this button will not visible once you deploy the application. Once you click the button, it will popup the Customization screen. Here you can change the layout of the screen, insert come new field or delete something which already exists. For now, we will not go with changing the layout or controls. I will cover them in another article.

    image

    Here, we will change the display name of the new student menu item. Select the top level node of the screen items and in the properties panel, change the “Display Name” from the default one to “New Student”. Now save the settings and restart the application for the changes to take effect. Once you run your application now, you will see the display name of the menu item has been changed to the entered value, i.e. “New Student”. This is more meaningful than the default text.

    image

    If you want to do the same thing inside the Visual Studio IDE, go to the properties pane as shown in the below figure. Find the “Display Name” property and change the display name to your own meaningful name. Run the application to see it in action.

    image

    You can change many other properties from the properties panel too.

    %d bloggers like this: