I wrote a winform in C #.ProgramThe error "sqldbtype enumeration value 31 is invalid" appears on the machine of the business department, as shown in:
This program runs normally on my own machine:
Then I open the debug mode of the Program on the machine of the business department (the program command line is followed by the/debug parameter, and the screen below is captured on my own machine ):
Run this program again to get more detailed error information:
It can be seen that it is skyiv. ben. ICBC. MIS. mgr. the getvalues method of the accbalance class in the Data namespace calls system. data. an error occurred while constructing the sqlparameter class in the sqlclient namespace. The getvalues method of the accbalance class is as follows:
Namespace skyiv. ben. ICBC. MIS. mgr. data {sealed class accbalance: dbobject {public accbalance (string newconnectionstring): Base (newconnectionstring) {} public sqldatareader getvalues (datetime datebegin, datetime dateend) {sqlparameter [] P = {New sqlparameter ("@ datebegin", sqldbtype. date), new sqlparameter ("@ dateend", sqldbtype. date)}; P [0]. value = datebegin; P [1]. value = dateend; return runreader ("prmgr_getaccbalancebydaterange", P );}}}
It seems that the sqldbtype. Date enumerated value is 31. Let's write a program to verify it:
Using system; using system. data; namespace skyiv. tester {sealed class sqldbtypetester {static void main () {try {console. writeline ("OS version:" + environment. osversion); console. writeline ("CLR version:" + environment. version); console. writeline (); listenummembers (typeof (sqldbtype);} catch (exception ex) {console. writeline (Ex) ;}} static void listenummembers (type) {console. writeline ("{0} members:", type); foreach (VaR value in Enum. getvalues (type) console. writeline ("{0, 3} {1}", (INT) value, value );}}}
Compile and run on my own machine:
E: \ CS \ hzb \ sqldbtype>CSC sqldbtypetester. CSMicrosoft (r) Visual C #3.5 compiler 3.5.21022.8 for Microsoft (R). Net Framework 2008 is copyrighted (c) Microsoft Corporation. Reserve all rights E: \ CS \ hzb \ sqldbtype>SqldbtypetesterOS Version: Microsoft Windows NT 5.1.2600 Service Pack 3clr version: 2.0.50727.1882System. data. sqldbtype members: 0 bigint 1 binary 2 bit 3 char 4 datetime 5 decimal 6 float 7 image 8 int 9 money 10 nchar 11 ntext 12 nvarchar 13 real 14 uniqueidentifier 15 smalldatetime 16 smallint 17 smallmoney 18 text 19 Timestamp 20 tinyint 21 varbinary 22 varchar 23 variant 25 XML 29 UDT30 structured31 date32 time 33 datetime2 34 datetimeoffsetE: \ CS \ hzb \ sqldbtype>
Indeed. Then copy the sqldbtypetester.exe program to the machine of the business department and run it:
D: \ sqldbtype>SqldbtypetesterOS Version: Microsoft Windows NT 5.1.2600 Service Pack 3clr version: 2.0.50727.832System. data. sqldbtype members: 0 bigint 1 binary 2 bit 3 char 4 datetime 5 decimal 6 float 7 image 8 int 9 money 10 nchar 11 ntext 12 nvarchar 13 real 14 uniqueidentifier 15 smalldatetime 16 smallint 17 smallmoney 18 text 19 Timestamp 20 tinyint 21 varbinary 22 varchar 23 variant 25 XML 29 udte: \ CS \ hzb \ sqldbtype>
Expired. sqldbtype. Date With the enumerated value 31 is missing. It is no wonder that the error "invalid sqldbtype enumeration value 31" will occur when running the winform program on the machine of the business department. The CLR version on my machine is 2.0.50727.1882, And the CLR version on the business department machine is 2.0.50727.832, that is, 2.0 RTM. It seems that this error is caused by the low. Net CLR version. After installing. NET Framework 2.0 SP2 on a machine in the business department, this problem is solved. See "Microsoft. NET Framework Version ".
Compile and run in the mono 2.6.7 environment of ubuntu 10.10:
Ben@ben-m4000t :~ /Work/sqldbtype $GMCs -- versionMono C # compiler version 2.6.7.0ben @ ben-m4000t :~ /Work/sqldbtype $GMCs sqldbtypetester. CS-R: system. Data. dllBen@ben-m4000t :~ /Work/sqldbtype $./Sqldbtypetester.exeOS Version: Unix 2.6.35.24clr version:2.0.50727.1433System. data. sqldbtype members: 0 bigint 1 binary 2 bit 3 char 4 datetime 5 decimal 6 float 7 image 8 int 9 money 10 nchar 11 ntext 12 nvarchar 13 real 14 uniqueidentifier 15 smalldatetime 16 smallint 17 smallmoney 18 text 19 Timestamp 20 tinyint 21 varbinary 22 varchar 23 variant 25 XML 29 UDT 31 date 32 timeben @ ben-m4000t: ~ /Work/sqldbtype $
Compile and run in the mono 2.8.1 environment of ubuntu 10.10:
Ben@ben-m4000t :~ /Work/sqldbtype $/Opt/mono-2.8.1/bin/DMCS -- versionMono C # compiler version 2.8.1.0ben @ ben-m4000t :~ /Work/sqldbtype $/Opt/mono-2.8.1/bin/DMCS sqldbtypetester. CS-R: system. Data. dllBen@ben-m4000t :~ /Work/sqldbtype $/Opt/mono-2.8.1/bin/MONO sqldbtypetester.exeOS Version: Unix 2.6.35.24clr version:4.0.30319.1System. data. sqldbtype members: 0 bigint 1 binary 2 bit 3 char 4 datetime 5 decimal 6 float 7 image 8 int 9 money 10 nchar 11 ntext 12 nvarchar 13 real 14 uniqueidentifier 15 smalldatetime 16 smallint 17 smallmoney 18 text 19 Timestamp 20 tinyint 21 varbinary 22 varchar 23 variant 25 XML 29 UDT 31 date 32 timeben @ ben-m4000t: ~ /Work/sqldbtype $
Run the following command in CLR 10.10 of Mono 2.6.7 of ubuntu 1.1:
Ben @ ben-m4000t :~ /Work/sqldbtype $ . /sqldbtypetester.exe warning: the runtime version supported by this application is unavailable. using default runtime: v1.1.4322 OS version: Unix 2.6.35.24clr version: 1.1.4322.2032 system. data. sqldbtype members: 0 bigint 1 binary 2 bit 3 char 4 datetime 5 decimal 6 float 7 image 8 int 9 money 10 nchar 11 ntext 12 nvarchar 13 real 14 uniqueidentifier 15 smalldatetime 16 smallint 17 smallmoney 18 text 19 timestamp 20 tinyint 21 varbinary 22 varchar 23 variantben @ ben-m4000t :~ /Work/sqldbtype $