Home > database >  How to 15 id number accurate upgrade to 18, thank you directly!
How to 15 id number accurate upgrade to 18, thank you directly!

Time:09-19

Each teacher hello! I have a Access data tables, there are some id number is 15, how do I do can be accurate to upgrade them to 18 id card number? I know only a little, please teach the teachers use the simplest way to thank you!

CodePudding user response:

The following code compiled with asp, can achieve your requirements, such as don't want to use asp, according to the idea to use a common language to write can you,

<%

The function convertsfz (insfzh) 'id number in 2 turns 18 function
STR=""
Str_len=0
RetStr=""
Tempstr=""
I=0
Ll_Sum=0
S=Array (" 1 ", "0", "X", "9", "eight", "7", "6", "5", "4", "3", "2")
N=Array (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1)
RetStr=""
Str_len=len (insfzh)
If 15 or str_len str_len==17 then
If str_len=15 then 'supplement year
RetStr=mid (insfzh, 1, 6) + "19" + mid (insfzh, 7, 15)
The else
RetStr=insfzh '17 only computing parity
End the if
For I=1 to 17
Tempstr=mid (retStr, I, 1)
Ll_Sum=ll_Sum + CDBL (tempstr) * N (I - 1)
Response. Write (tempstr&" | "& amp; Ll_Sum & amp;" | "& amp; (ll_Sum mod 11) & amp;"
" )
Next
RetStr=retStr & amp; S (ll_Sum mod 11)
The else
RetStr=insfzh
End the if
Convertsfz retStr=
End the Function

The set myconn=server. Createobject (" ADODB. CONNECTION ")
StrSQL="Provider=Microsoft. Jet. The OLEDB. 4.0. Data Source="& amp; Server. MapPath (" your access database name ")
Myconn. Open StrSQL

Set the rs=myconn. Execute (" select id, id number from your data table name where len (id)=15 ")
If not rs. Eof then varr=rs. Getrows () end if
Rs. Close
Set the rs=nothing

If isarray (varr) then
Vend=ubound (varr, 2)
For I=0 to vend
Vid=varr (0, I)
VSFZH=rs (1, I)
Myconn. Execute (" update mytab set id='" & amp; Convertsfz (VSFZH) & amp;" 'where ID="& amp; Vid)
Next
End the if

Myconn. Close
The set myconn=nothing

Response. Write (", ")
%>
  • Related