.NET Questions and Solutions

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘database’

FIX: A System.NullReferenceException exception occurs when you deploy a composite database project in Microsoft Visual Studio Team System 2008 Database Edition GDR

Symptoms
Consider the following scenario in Microsoft Visual Studio Team System 2008 Database Edition GDR: You have a database project that includes tables.You have another database project that includes constraints for the tables in the same solution and you add a reference to the database project that includes tables.You connect both projects to the same target database on a server.Then, you deploy the projects to the database.In this scenario, you receive a System.NullReferenceException exception and then the Visual Studio IDE crashes. If you debug this exception, you receive the following error message:

System.NullReferenceException: Object reference not set to an instance of an object.
Resolution
To resolve this problem, upgrade to Microsoft Visual Studio Team System 2008 Database Edition GDR R2. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
970479?(http://support.microsoft.com/kb/970479/) List of fixed issues in the Microsoft Visual Studio Team System 2008 Database Edition GDR R2
Note Microsoft Visual Studio Team System 2008 Database Edition GDR R2 replaces Microsoft Visual Studio Team System 2008 Database Edition GDR.

Description of database normalization basics in Access 2000

Symptoms
This article explains database normalization terminology for beginners. A basic understanding of this terminology is helpful when discussing the design of a relational database.
NOTE: Microsoft also offers a WebCast that discusses the basics of database normalization. To view this WebCast, please visit the following Microsoft Web site:
http://support.microsoft.com/servicedesks/webcasts/wc060600/wc060600.asp?fr=1(http://support.microsoft.com/?scid=http%3a%2f%2fsupport.microsoft.com%2fservicedesks%2fwebcasts%2fwc060600%2fwc060600.asp%3ffr%3d1) For additional information about this topic in an earlier version of Access, click the following article number to view the article in the Microsoft Knowledge Base:
100139?(http://support.microsoft.com/kb/100139/) Database normalization basics
Resolution
Description of normalization Normalization is the process of organizing data in a database. This includes creating tables and establishing relationships between those tables according to rules designed both to protect the data and to make the database more flexible by eliminating redundancy and inconsistent dependency.
Redundant data wastes disk space and creates maintenance problems. If data that exists in more than one place must be changed, the data must be changed in exactly the same way in all locations. A customer address change is much easier to implement if that data is stored only in the Customers table and nowhere else in the database.
What is an “inconsistent dependency”? While it is intuitive for a user to look in the Customers table for the address of a particular customer, it may not make sense to look there for the salary of the employee who calls on that customer. The employee’s salary is related to, or dependent on, the employee and thus should be moved to the Employees table. Inconsistent dependencies can make data difficult to access because the path to find the data may be missing or broken.
There are a few rules for database normalization. Each rule is called a “normal form.” If the first rule is observed, the database is said to be in “first normal form.” If the first three rules are observed, the database is considered to be in “third normal form.” Although other levels of normalization are possible, third normal form is considered the highest level necessary for most applications.
As with many formal rules and specifications, real world scenarios do not always allow for perfect compliance. In general, normalization requires additional tables and some customers find this cumbersome. If you decide to violate one of the first three rules of normalization, make sure that your application anticipates any problems that could occur, such as redundant data and inconsistent dependencies.
The following descriptions include examples.
First normal formEliminate repeating groups in individual tables. Create a separate table for each set of related data. Identify each set of related data with a primary key. Do not use multiple fields in a single table to store similar data. For example, to track an inventory item that may come from two possible sources, an inventory record may contain fields for Vendor Code 1 and Vendor Code 2.
What happens when you add a third vendor? Adding a field is not the answer; it requires program and table modifications and does not smoothly accommodate a dynamic number of vendors. Instead, place all vendor information in a separate table called Vendors, then link inventory to vendors with an item number key, or vendors to inventory with a vendor code key.
Second normal formCreate separate tables for sets of values that apply to multiple records. Relate these tables with a foreign key. Records should not depend on anything other than a table’s primary key (a compound key, if necessary). For example, consider a customer’s address in an accounting system. The address is needed by the Customers table, but also by the Orders, Shipping, Invoices, Accounts Receivable, and Collections tables. Instead of storing the customer’s address as a separate entry in each of these tables, store it in one place, either in the Customers table or in a separate Addresses table.
Third normal formEliminate fields that do not depend on the key. Values in a record that are not part of that record’s key do not belong in the table. In general, any time the contents of a group of fields may apply to more than a single record in the table, consider placing those fields in a separate table.
For example, in an Employee Recruitment table, a candidate’s university name and address may be included. But you need a complete list of universities for group mailings. If university information is stored in the Candidates table, there is no way to list universities with no current candidates. Create a separate Universities table and link it to the Candidates table with a university code key.
EXCEPTION: Adhering to the third normal form, while theoretically desirable, is not always practical. If you have a Customers table and you want to eliminate all possible interfield dependencies, you must create separate tables for cities, ZIP codes, sales representatives, customer classes, and any other factor that may be duplicated in multiple records. In theory, normalization is worth pursing. However, many small tables may degrade performance or exceed open file and memory capacities.
It may be more feasible to apply third normal form only to data that changes frequently. If some dependent fields remain, design your application to require the user to verify all related fields when any one is changed.
Other normalization forms Fourth normal form, also called Boyce Codd Normal Form (BCNF), and fifth normal form do exist, but are rarely considered in practical design. Disregarding these rules may result in less than perfect database design, but should not affect functionality.
Normalizing an example table These steps demonstrate the process of normalizing a fictitious student table. Unnormalized table:
Collapse this tableExpand this table
Student#AdvisorAdv-RoomClass1Class2Class31022Jones412101-07143-01159-024123Smith216201-01211-02214-01First Normal Form: No Repeating Groups
Tables should have only two dimensions. Since one student has several classes, these classes should be listed in a separate table. Fields Class1, Class2, and Class3 in the above records are indications of design trouble.
Spreadsheets often use the third dimension, but tables should not. Another way to look at this problem is with a one-to-many relationship, do not put the one side and the many side in the same table. Instead, create another table in first normal form by eliminating the repeating group (Class#), as shown below:
Collapse this tableExpand this table
Student#AdvisorAdv-RoomClass#1022Jones412101-071022Jones412143-011022Jones412159-024123Smith216201-014123Smith216211-024123Smith216214-01Second Normal Form: Eliminate Redundant Data
Note the multiple Class# values for each Student# value in the above table. Class# is not functionally dependent on Student# (primary key), so this relationship is not in second normal form.
The following two tables demonstrate second normal form: Students
Collapse this tableExpand this table
Student#AdvisorAdv-Room1022Jones4124123Smith216Registration
Collapse this tableExpand this table
Student#Class#1022101-071022143-011022159-024123201-014123211-024123214-01Third Normal Form: Eliminate Data Not Dependent On Key
In the last example, Adv-Room (the advisor’s office number) is functionally dependent on the Advisor attribute. The solution is to move that attribute from the Students table to the Faculty table, as shown below:Students
Collapse this tableExpand this table
Student#Advisor1022Jones4123SmithFaculty
Collapse this tableExpand this table
NameRoomDeptJones41242Smith21642

BizTalk Server may fail persisting state to the database and may end the orchestration instance

Symptoms
Microsoft BizTalk Server 2004 may fail while it tries to persist the state of an running orchestration instance to the database and throws a PersistenceException exception. BizTalk Server ends the running orchestration instance and you may receive an error message that is similar to the following:

Uncaught exception terminated service MYAPP.MyOrchestration(f56f3586-8c07-f8c8-fedf-3ac47aef7816), instance 7f6901e9-da3d-4166-b3f8-0e57f5b579e6
Exception occurred when persisting state to the database.
Exception type: PersistenceException
Source: Microsoft.XLANGs.BizTalk.Engine
Target Site: Void Commit()
Help Link:
Additional error information:
A batch item failed persistence Item-ID de31a76d-8a6a-440e-8e00-422ba9602127 OperationType MAIO_CommitBatch Status -1061151992 ErrorInfo The operation could not be performed because the message on which it was acting was not found in the database. .
Exception type: PersistenceItem
ExceptionSource:
Target Site:
Help Link:
Additional error information:
A batch item failed persistence Item-ID 983fac93-bbe0-466a-bed9-e49e10ad6e57 OperationType MAIO_ReceiveCompleteMessage Status -1061151992 ErrorInfo The operation could not be performed because the message on which it was acting was not found in the database. .
Exception type: PersistenceItem
ExceptionSource:
Target Site:
Help Link:
Additional error information: Exception occurred when persisting state to the database.
Exception type: Persistence
ExceptionSource: Microsoft.XLANGs.BizTalk.Engine
Target Site: Void Commit(Microsoft.BizTalk.Agent.Interop.IBTMessageBatchEx[], Microsoft.XLANGs.Core.Segment, Microsoft.BizTalk.Agent.Interop.IBTOperationStatus ByRef)
Help Link:
Additional error information:
A batch item failed persistence Item-ID de31a76d-8a6a-440e-8e00-422ba9602127 OperationType MAIO_CommitBatch Status -1061151992 ErrorInfo The operation could not be performed because the message on which it was acting was not found in the database. .
Exception type: PersistenceItem
ExceptionSource:
Target Site:
Help Link:
Additional error information:
A batch item failed persistence Item-ID 983fac93-bbe0-466a-bed9-e49e10ad6e57 OperationType MAIO_ReceiveCompleteMessage Status -1061151992 ErrorInfo The operation could not be performed because the message on which it was acting was not found in the database. .
Exception type: PersistenceItem
ExceptionSource:
Target Site:
Help Link:
Additional error information
Resolution
Service pack informationTo resolve this problem, obtain the latest service pack for Microsoft BizTalk Server 2004. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
888751?(http://support.microsoft.com/kb/888751/) How to obtain the latest BizTalk Server 2004 service pack
Hotfix information
The English version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

DateTimeVersionSizeFile name—————————————————————————-14-Apr-200416:073.0.5278.0217,088Microsoft.xlangs.biztalk.engine.dll14-Apr-200415:563.0.5278.0114,688Microsoft.xlangs.runtimetypes.dllNoteBecause of file dependencies, the most recent hotfix that contains these files may also contain additional files.

Asset Management reports in Systems Management Server 2003 Service Pack 3 contain information about obsolete computers

Symptoms
When you view the Asset Management reports in Microsoft Systems Management Server (SMS) 2003 Service Pack 3(SP3), the Asset Management reports contain information about obsolete computers.
Resolution
This behavior occurs because the Asset Management reports in SMS 2003 SP3 include all computers in the SMS database or in the specified collection. This may include computers that are marked as obsolete.Computers that are marked as obsolete are routinely removed from the SMS database when theautomatic deletion schedule occurs. However, if the automatic deletion schedule has not occurred, the obsolete computer information remains in the SMS database.

An unhandled exception may occur when you try to connect to an Access database from an ASP.NET worker process

Symptoms
An unhandled exception may occur under the following circumstances: An ASP.NET worker process (Aspnet_wp.exe) runs under the default ASPNET account.
-and-
You do not enable impersonation on that application.
-and-
You try to connect to or write to an Access database. Under these circumstances, you may receive one of the following exceptions:

The Microsoft Jet database engine cannot open the file ‘C:\Nwind.mdb’. It is already opened exclusively by another user, or you need permission to view its data.

Operation must use an updateable query.
Resolution
Because of security concerns, the ASP.NET worker process runs under the default ASPNET account. If you do not enable impersonation for an application, all of the threads that run the requests for that application run under the process account.
This problem occurs because the ASPNET account does not have sufficient permissions to connect to or write to an Access database.

ACC2000: VBA Functions Break in Database with Missing References

Symptoms
If you have a procedure that contains a Visual Basic for Applicationsfunction, and your database contains a reference to a missing objectlibrary or type library, you may receive the following error message whenyou compile your modules or run the procedure:

Compile Error:
Can’t find project or library
Resolution
Your database contains a reference to a database, type library, or objectlibrary that is marked as MISSING: <referencename> in the References dialog box.