Một số lỗi thường gặp trên Crystal Report

1 – Lỗi in trực tiếp Report trên form
================================================================================
1.1 – Failed to load database information.
Error in File rptInvoice {6A24503F-DEA3-44A3-9913-35800DAEA39C}.rpt:
Failed to load database information.
=> Nguyên nhân : Do crystal report thiết kế trên .NET Framework 2.0
tuy nhiên chương trình chạy trên VS2010(.Net 4.0) nên không tương thích
=> Cách khắc phục : Thêm addtribute “useLegacyV2RuntimeActivationPolicy”
trong file App.Config trong tab “Starup”
<startup>
<supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.0″ />
<supportedRuntime version=”v1.1″/>
<startup>

——————————————————————————–
1.2 – The table %1 does not exist in the document.
=> Nguyên nhân : Do chưa login thành công vào server (lỗi 1.1) nên chưa thấy
được metadata của table vì vậy truy xuất vào một trong những table bên trong sẽ
bị lỗi.
=> Cách khắc phục : Xem lỗi (1.1)

——————————————————————————–
1.3 – Lỗi show report lên trắng hoặc không có gì thể hiện
=> Nguyên nhân :
– Do report gọi từ store, table không chứa dữ liệu.
– Do Report document không thiết lập được parameter values vào store.
=> Cách khắc phục :
– Cách thiết lập report parameter cũ của report document chập chờn
– Thiết lập theo cách mới :
Dim obj As New ParameterDiscreteValue
obj.Value = “XXX”
Dim objParameterField = crViewer.ParameterFieldInfo(“@pstrXXX”)
objParameterField.CurrentValues.Add(obj)
sửa được 1 lỗi view report không có data -> ra report trắng
Trường hợp report có sourceData là store:
Nếu store này có kết quả trả về bằng cách thực thi 1
exec thì sẽ bị lỗi trên VS2010 là không có data
Khắc phục: insert kết quả vào bảng tạm (#table) rồi
Select * from #table này thì ok, report lên data bình thường,

2 – Lỗi in trên report dialog

================================================================================
2.1 – Lỗi Invalid Index khi show report
=> Nguyên nhân : Do thư viện gán PrintOptions.PaperSize = mintPageIdty,
mà Papersize là enum có giá trị trong Range
= > Cách khắc phục :
——————————————————————————–
2.2 – Failed to load database information.
=> Nguyên nhân : Do không apply và verify login information vào connection
của report document
=> Cách khắc phục : Đối với từng connection của report document, phải gián
thông tin login và verify database trước khi gán vào cho từng table.
——————————————————————————–
2.3 – File or assembly name crystaldescistion.shared or one of its dependencies
………not found
=> Chép các file dependency này vào thư mục thực thi của chương trình

3 – Lỗi khác lúc runtime
================================================================================
3.1 – ReportDocument
=> Lỗi : COM object that has been separated from its underlying RCW cannot
be used
=> Nguyên nhân : Lỗi COM
=> Cách khắc phục :
– Phải đóng Report Document trước khi mở cái mới
– Đóng form trong form main
Private Sub frmMain_FormClosing(sender As System.Object, e As System.
Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
For i As Integer = Application.OpenForms.Count – 1 To 0 Step -1
If Application.OpenForms(i).Name <> Me.Name Then
Application.OpenForms(i).Close()
End If
Next
End Sub

 

3.2 – Error in formula
——————————————————————————–
=> Lỗi :
This field name is not known.
Details: errorKind
Error in File XXXX_cc {1793C34D-519B-42B0-A240-AAA5648A154E}.rpt:
Error in formula vMainCode:
” ‘ + {.MainCode}’
This field name is not known.
Details: errorKind
=> Nguyên nhân :
=> Cách khắc phục :
không set được khổ giấy phiếu thu,hóa đơn

3.4 – Lỗi khi show report với nhiều table

——————————————————————————–

=> Chi tiết lỗi :
Logon failed.
Error in File XXX {9BF6BA9E-40DE-4AAB-847F-ED1163D04678}.rpt:
Unable to connect: incorrect log on parameters.
=> Test report : RPRTASSET
=> Test : User 015674, báo biểu/tài sản/tài sản
– File name : XXX.rpt
=> Cách khắc phục : bỏ chế độ “Intergrated Security” trong report location
xem hình : 2012-09-24_143715.png

3.5 – Operation illegal on linked parameter
——————————————————————————–
Error in File rpt_spsplrimportreport {F7F90E54-D6B9-42D4-AB99-9EECD8838B0E}.rpt:
Operation illegal on linked parameter.

3.7 – UFL ‘u25idautomation.dll’ that implements this function is missing.

——————————————————————————–
UFL ‘u25idautomation.dll’ that implements this function is missing.
=> Nguyên nhân : Khi sử dụng crystal report có barcode, thì có sử dụng thư viện UFL (User Function
Libraries) những thư viện này hỗ trợ dịch barcode fonts.

=> Cách khắc phục :
– Cài đặt thư viện này
– Hoạc không dùng thư viện mà dùng fornular.

3.8 – Lỗi khi chạy trên Windows 64bit
——————————————————————————–
An error has occurred while attempting to load the Crystal Reports runtime.
Either the Crystal Reports registry key permissions are insufficient or the Crystal Reports runtime
is not installed correctly.
Please install the appropriate Crystal Reports redistributable (CRRedist*.msi) that contains
the version of the Crystal Reports runtime (x86, x64, or Itanium) that is required.
Please go to http://www.businessobjects.com/support for more information.

=> Nguyên nhân : Crystal report chưa hỗ trợ Windows 64bit
=> Cách khắc phục :
– Sửa compiler option thành Windows X86

Table hệ thống trong SQL Server 2008 R2 (Phần 02) – Sys.Columns

Sys.Columns :

Table lưu trữ các column được định nghĩa trong table và views.

Kiến trúc table :

Column name Data type Description
object_id int ID of the object to which this column belongs.
name sysname Name of the column. Is unique within the object.
column_id int ID of the column. Is unique within the object.

Column IDs might not be sequential.

system_type_id tinyint ID of the system type of the column.
user_type_id int ID of the type of the column as defined by the user.

To return the name of the type, join to the sys.types catalog view on this column.

max_length smallint Maximum length (in bytes) of the column.

-1 = Column data type is varchar(max), nvarchar(max), varbinary(max), or xml.

For text columns, the max_length value will be 16 or the value set by sp_tableoption ‘text in row’.

precision tinyint Precision of the column if numeric-based; otherwise, 0.
scale tinyint Scale of column if numeric-based; otherwise, 0.
collation_name sysname Name of the collation of the column if character-based; otherwise, NULL.
is_nullable bit 1 = Column is nullable.
is_ansi_padded bit 1 = Column uses ANSI_PADDING ON behavior if character, binary, or variant.

0 = Column is not character, binary, or variant.

is_rowguidcol bit 1 = Column is a declared ROWGUIDCOL.
is_identity bit 1 = Column has identity values
is_computed bit 1 = Column is a computed column.
is_filestream bit 1 = Column is a FILESTREAM column.
is_replicated bit 1 = Column is replicated.
is_non_sql_subscribed bit 1 = Column has a non-SQL Server subscriber.
is_merge_published bit 1 = Column is merge-published.
is_dts_replicated bit 1 = Column is replicated by using SSIS.
is_xml_document bit 1 = Content is a complete XML document.

0 = Content is a document fragment or the column data type is not xml.

xml_collection_id int Nonzero if the data type of the column is xml and the XML is typed. The value will be the ID of the collection containing the validating XML schema namespace of the column.

0 = No XML schema collection.

default_object_id int ID of the default object, regardless of whether it is a stand-alone object sys.sp_bindefault, or an inline, column-level DEFAULT constraint. The parent_object_id column of an inline column-level default object is a reference back to the table itself.

0 = No default.

rule_object_id int ID of the stand-alone rule bound to the column by using sys.sp_bindrule.

0 = No stand-alone rule. For column-level CHECK constraints, see sys.check_constraints (Transact-SQL).

is_sparse bit 1 = Column is a sparse column. For more information, see Using Sparse Columns.
is_column_set bit 1 = Column is a column set. For more information, see Using Sparse Columns.

 

Lưu ý:

Trong Sys.Columns sẽ có object_id  sẽ tham chiếu đến table hoặc view

SELECT c.* FROM sys.objects o JOIN sys.columns c
on o.object_id = c.object_id

Table hệ thống trong SQL Server 2008 R2 (Phần 01) – Sys.Objects

Kính gửi các bạn,

Sau đây tôi xin liệt kê các table, View hệ thống trong hệ quản trị CSDL SQL Server 2008. Nhằm giúp ích cho người lập trình cũng như người quản trị hệ thống CSDL có thể hiểu rõ và điều khiển hệ thống của mình một cách nhanh và hiệu quả nhất.

SYS : là một trong schema hệ thống của SQL Server chứa table, view hệ thống. Table Sys.Objects này lưu trữ thông tin về các loại đối tượng trong hệ quản trị CSDL. Ví dụ : khi bạn tạo một table, view, store procedure…. bằng câu lệnh DDL (Data Define Language) như : Create, các đối tượng này được lưu trữ vào table hệ thống sys.objects

Cấu trúc table Sys.Objects

Column name Data type  Description
name sysname Object name
id int Object identification number
xtype char(2) Object type. Can be one of the following object types:

AF = Aggregate function (CLR)

C = CHECK constraint

D = Default or DEFAULT constraint

F = FOREIGN KEY constraint

L = Log

FN = Scalar function

FS = Assembly (CLR) scalar-function

FT = Assembly (CLR) table-valued function

IF = In-lined table-function

IT = Internal table

P = Stored procedure

PC = Assembly (CLR) stored-procedure

PK = PRIMARY KEY constraint (type is K)

RF = Replication filter stored procedure

S = System table

SN = Synonym

SQ = Service queue

TA = Assembly (CLR) DML triggerTF = Table function

TR = SQL DML Trigger

TT = Table type

U = User table

UQ = UNIQUE constraint (type is K)

V = View

X = Extended stored procedure

uid smallint Schema ID of the owner of the object.

For databases upgraded from an earlier version of SQL Server, the schema ID is equal to the user ID of the owner.

Important:
If you use any of the following SQL Server DDL statements, you must use the sys.objects catalog view instead of sys.sysobjects.CREATE | ALTER | DROP USERCREATE | ALTER | DROP ROLECREATE | ALTER | DROP APPLICATION ROLECREATE SCHEMAALTER AUTHORIZATION ON OBJECT

Overflows or returns NULL if the number of users and roles exceeds 32,767.

For more information, see Querying the SQL Server System Catalog.

info smallint Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
status int Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
base_schema_ver int Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
replinfo int Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
parent_obj int Object identification number of the parent object. For example, the table ID if it is a trigger or constraint.
crdate datetime Date the object was created.
ftcatid smallint Identifier of the full-text catalog for all user tables registered for full-text indexing, and 0 for all user tables that are not registered.
schema_ver int Version number that is incremented every time the schema for a table changes. Always returns 0.
stats_schema_ver int Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
type char(2) Object type. Can be one of the following values:

AF = Aggregate function (CLR)

C = CHECK constraint

D = Default or DEFAULT constraint

F = FOREIGN KEY constraint

FN = Scalar function

FS = Assembly (CLR) scalar-function

FT = Assembly (CLR) table-valued functionIF = In-lined table-function

IT – Internal table

K = PRIMARY KEY or UNIQUE constraint

L = Log

P = Stored procedure

PC = Assembly (CLR) stored-procedure

R = Rule

RF = Replication filter stored procedure

S = System table

SN = Synonym

SQ = Service queue

TA = Assembly (CLR) DML trigger

TF = Table function

TR = SQL DML Trigger

TT = Table type

U = User table

V = View

X = Extended stored procedure

userstat smallint Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
sysstat smallint Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
indexdel smallint Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
refdate datetime Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
version int Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
deltrig int Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
instrig int Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
updtrig int Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
seltrig int Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
category int Used for publication, constraints, and identity.
cache smallint Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.

Khi muốn tìm một đối tượng nào theo tên hoặc theo kiểu đối tượng, chúng ta có thể sử dụng câu SQL:

SELECT * from sys.objects

Tìm tất cả các table trong database

SELECT * from sys.objects where type = ‘U’

Tìm tất cả view trong database

SELECT * from sys.objects where type = ‘V’

=> Tùy thuộc vào “type” các bạn có thể tìm các đối tượng.

Tìm hiểu các thư mục hệ thống trong Windows 32bit và Windows 64bit

Windows 64-bit:

The ‘Program Files (x86)’ and ‘SysWOW64’ folders explained



If you use a 64-bit computer with a 64-bit Windows installed (for example the 64-bit version of Windows 7) you have probably discovered that there are two new folders with the names Program Files (x86) and SysWOW64 on the harddisk, that do not exist on a 32-bit Windows. Maybe you have wondered what these folders are, why they exist and what kind of files they contain? In this article we will explain these folders and also explain why it is important to place with files with a specific bitness (32 or 64 bit) in the right folder on the harddisk.

32-bit versus 64-bit computers and Windows

Since the mid-90s almost all computers that have been sold have been 32-bit computers, and mostly they have had a 32-bit Windows installed. But after the release of Windows 7, the sales of 64-bit computers with a 64-bit Windows installed have increased a lot. In the coming years, more and more people will have a 64-bit computer with a 64-bit Windows in their home or office. One reason to this is that the price of a 64-bit computer have decreased so much that they are almost as cheap as 32-bit computers. And people will prefer 64-bit computers over 32-bit computers because they can handle much more (RAM) memory.

A 32-bit computer with a 32-bit Windows installed can use a maximum of 3 to 4 GB (RAM) memory. Mostly around 3 GB because a large part of the address space is used by video cards and other devices such as network cards, sound cards etc. This is true even if you install 4 GB in the computer. Mostly only around 3 GB RAM will still be used. With 64-bit computers and 64-bit Windows things are different. A 64-bit computer with a 64-bit Windows can handle so much RAM memory as 192 GB!

On a 64-bit Windows, both 32-bit and 64-bit programs can be run

Both 32-bit and 64-bit programs can be run on a 64-bit Windows. When a 32-bit program is run on a 64-bit Windows, a 32-bit emulator will be invoked to handle the 32-bit program.

The emulator will make the 32-bit application to think it is running on a 32-bit Windows and the same functionality that is accessible on a 32-bit Windows will also be accessible for the program on the 64-bit Windows. Normally it will be hard for the program to know if it is running on a 32-bit or 64-bit system, but if the program really needs to know the difference there are API functions available that the program can call if needed.
Exceptions: Antivirus programs etc
There are a few exceptions from this. 32-bit programs that function at low level, such as antivirus programs, will not always work on a 64-bit Windows; then a 64-bit version of the program must be used.

During the installation, it is important to install files into correct folders

As mentioned above the 32-bit emulator handles the situations when 32-bit programs are run on a 64-bit Windows and normally this works fine. But one sensitive phase is the installation of the 32-bit program. There exists special folders on the harddisk that is intended for 32-bit binary files only and it is very important that the installation program installs the 32-bit binary files to these folders. Some folders on the harddisk are intended for 32-bit binary files only and other folders are intended for 64-bit binary files only. If you place binary file with a specific bitness (32/64 bit) in a folder intended for another bitness the program will probably fail to work properly; in many cases the program will not even start.

Examples of binary files that is mentioned in this article are EXE files (program files), DLL files and OCX files (ActiveX components). Data files can usually placed in same folders and shared by both a 32 and 64 bit application.

Two different versions of the Program Files folder and the Windows System folder

A 64-bit Windows has two different versions of the program files folder and the Windows system folder (system directory). One version is intended for 32-bit files and other version is intended for 64-bit files. The name of these folders, and the bitness they are intended for, is shown in the table below:

Folder name Bitness Description
System32 64 Windows System folder (system directory) for 64-bit files
SysWOW64 32 Windows System folder (system directory) for 32-bit files
Program Files 64 Folder for 64-bit program files
Program Files (x86) 32 Folder for 32-bit program files


Below you can see the full path to the folders.

Folder name Folder path Description
System32 C:\Windows\System32 Windows System folder (system directory) for 64-bit files
SysWOW64 C:\Windows\SysWOW64 Windows System folder (system directory) for 32-bit files
Program Files C:\Program Files Folder for 64-bit program files
Program Files (x86) C:\Program Files (x86) Folder for 32-bit program files

The ‘System32’ folder is for 64-bit files and the ‘SysWOW64’ folder is for 32-bit files

This can be somewhat confusing, but the System32 folder is intended for 64-bit files and the SysWOW64 folder is intended for 32-bit files. This may seem a bit illogical if you look at the folder names, but there is an explanation to this. It has to do with compatibility. Many developers have hard coded the system folder path name in their applications source code and to preserve compatibility, if the application is converted to 64-bit code, the 64-bit system folder is still namedSystem32.

But what about 32-bit applications that have the system path hard coded and is running in a 64-bit Windows? How can they find the new SysWOW64 folder without changes in the program code, you might think. The answer is that the emulator redirects calls to System32 folder to the SysWOW64 folder transparently so even if the folder is hard coded to the System32 folder (like C:\Windows\System32), the emulator will make sure that the SysWOW64 folder is used instead. So same source code, that uses the System32 folder, can be compiled to both 32-bit and 64-bit program code without any changes.

So remember:

 the SysWOW64 folder is intended for 32-bit files only
 the System32 folder is intended for 64-bit files only

It is very important that a binary file compiled to a specific bitness (32 or 64) is installed to the correct system folder. Otherwise the program that needs the file will not be able to load the file and will probably not work as expected.

The ‘Program Files’ and ‘Program Files (x86)’ folders

If you have a 64-bit Windows installed on your computer you have probably already noticed that there exists two folders for program files: the Program Files folder and the Program Files (x86) folder. The Program Files folder is intended for 64-bit programs and the Program Files (x86) folder is intended for 32-bit programs.

In many cases the program will start and run as expected even if you place the program in wrong folder, but if the program asks Windows for the path to the Program Files folder and want to access installed files in the folder, the wrong folder will be used and the program will likely fail to function. So to be sure that everything always works as expected, you should always install files with a specific bitness to the correct Program Files folder. So on a 64-bit computer with a 64-bit Windows, remember this:

 always install a 32-bit program into the Program Files (x86) folder
 always install a 64-bit program into the Program Files folder

Supported by all Windows versions

This method of naming 32 and 64 bit folders are supported by all 64-bit Windows on the market. Both client versions and server versions of Windows support this. The following Windows versions support this naming system: Windows XP, Windows Vista, Windows 7, Windows 8 and Windows Server 2003 / 2008 / 2012.

‘WOW64’ and ‘x86’, what do they mean?

SysWOW64 and Program Files (x86) are special folders that only exists on 64-bit Windows and they are intended to store 32-bit binary files. In the folder names there are the “strange” character combinations WOW64 and x86 included. These character combinations have a meaning and we will explain it below:

 WOW64 is a shortening for ”Windows on Windows 64-bit” (can be read as “Windows 32-bit on Windows 64-bit”). It’s a emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows. A compatibility layer is used as an interface between the 32-bit program and the 64-bit operating system.

 x86 is the name of a processor architecture from Intel that handles 32 bit instruction sets. The x86 term have been used for a very long time and in the beginning it was used as a general term to refer to Intel 16/32 bit processors with names such 8086, 80186, 80286, 80386 etc. But since the release of the 80386 processor, the first real 32 bit processor, the term x86 have been used to refer to 32-bit processors that have an instruction set that is compatible with the old 80386 processor.

 

Nguồn :

http://www.samlogic.net/articles/32-64-bit-windows-folder-x86-syswow64.htm
 

More information

If you want to have more information about the different versions of the Program Files and System folder, and have a general overview of the WOW64 technology, you should read the document Best Practices for WOW64 from Microsoft.

More information is also available in our article The ‘Program Files’ folder in different languages.