您正在使用 IPV6 [2600:1f28:365:80b0:6a83:1b0d:c53:cecc] 访问本站,您本次已经查看了 1 页
用户名: 密 码: 验证码:     用QQ登录本站
首页 软件 编程 笑话 知识 公告 台风 日历 计算器
[公益]保护绿色环境,构建和谐社会      

【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中      
【腾讯云】618年中盛惠,2核2G5M云服务器低至 68元/年       [公益] 地球是我家,绿化靠大家       广州婚姻调查公司      
2025年 七夕节 071
2025年 教师节 083
2026年 元 旦 196
2026年 春 节 243
综合数码金融娱乐服务报刊政府机构 推荐 排名 今日 申请 友情  
您现在的位置:首页 >> ASP/ASP.net >> 内容
本类新增
本类热门
asp中用数据库生成不重复的流水号
内容摘要: '*************************************************'函数名:getMaxOrder'作用:得到最大序列号'参数:fieldName----在序列号表中的字段名'tableName----序列号所在表名'fieldName----在表中的字段名'返回值:字段的最大值'调用函数:idAdd:作用见上'******......
'*************************************************

'函数名:getMaxOrder

'作用:得到最大序列号

'参数:fieldName----在序列号表中的字段名

'tableName----序列号所在表名

'fieldName----在表中的字段名

'返回值:字段的最大值

'调用函数:idAdd:作用见上

'*************************************************

functiongetMaxOrder(fieldName,tableName,tableFileName)

dimorderNO,orderRS,testRS

settestRS=Server.CreateObject("ADODB.recordset")

setorderRS=Server.CreateObject("ADODB.recordset")

firstNO=year(date)&right(("0"&month(date)),2)

orderSQL="select*fromfieldMaxValuewherefieldName='"&fieldName&"'"

orderRS.openorderSQL,conn,3,2

ifnotorderRS.eofthen

orderRS("fieldMaxValue")=orderRS("fieldMaxValue")

orderNO=orderRS("fieldMaxValue")

ifleft(orderNO,6)=firstNOthen

orderNO=idAdd(orderNO)

else

orderNO=firstNO&"00001"

endif

else

orderRS.addnew

orderRS("fieldName")=fieldName

orderNO=firstNO&"00001"

endif

testRS.open"selectmax("&tableFileName&")from"&tableName&"where"&tableFileName&"like'"&firstNO&"%'",conn,1,2

if(nottestRS.eof)andtestRS(0).value>orderNOthen

orderNO=idAdd(testRS(0).value)

endif

testRS.close

settestRS=nothing

orderRS("fieldMaxValue")=orderNO

orderRS.update

orderRS.close

setorderRS=nothing

getMaxOrder=orderNO

endfunction

'*************************************************

'函数名:idAdd

'作用:用来增加一:比如idAdd("5")="6",idAdd("L99")="M00",idAdd("!")="!1"

'如果是数字就到9后进位,如果是小写字母到期z后进位

'如果是大写字母到Z后进位,其它在后面加一个1

'参数:id----需来增加的数

'返回值:增加后的数

'调用函数:addOne一个数增加一AddOne("5")="6",Add(9)="0",AddOne("a")="b",

'AddOne("z")="a",AddOne("A")="B",AddOne("Z")="A"

'*************************************************

FunctionAddOne(first)

Dimtempfirst

AddOne=first

intfirst=Asc(first)

If(intfirst>=48Andintfirst<57)Or(intfirst>=65Andintfirst<90)Or(intfirst>=97Andintfirst<122)Then

AddOne=Chr(intfirst+1)

ExitFunction

EndIf

If(intfirst=57)Then

AddOne="0"

ExitFunction

EndIf

If(intfirst=90)Then

AddOne="A"

ExitFunction

EndIf

If(intfirst=122)Then

AddOne="a"

ExitFunction

EndIf

EndFunction

FunctionidAdd(id)

Dimfornt,back,strFind,strBackFind,idLen,tempid

ifid=""orisNull(id)then

iddAdd=1

exitFunction

endif

tempid=id

idLen=Len(id)

Fori=1ToidLen

fornt=Left(id,idLen-i)

back=Right(id,i-1)

strFind=Mid(id,idLen+1-i,1)

strBackFind=AddOne(strFind)

id=fornt&strBackFind&back

IfstrFind<strBackFindThen

ExitFor

EndIf

IfstrFind>strBackFindThen

Ifi=idLenThen

id=id&"1"

Else

IfMid(id,idLen-i,1)=AddOne(Mid(id,idLen-i,1))Then

id=fornt&strBackFind&back&"1"

ExitFor

EndIf

EndIf

EndIf

Next

Ifid=tempidThen

id=id&"1"

EndIf

idAdd=id

EndFunction

'调用示例

serviceNO=getMaxOrder("serviceNO","service","serviceNO")

'其中保存所有字段流水号最大值的表的结构为:

表名:fieldMaxValue

字段

idfieldNamefieldMaxValue

版权声明:本内容来源于网络,如有侵犯您的版权,请联系站长,本站收到您的信息后将及时处理。
上一篇:返回执行长度的随机字符串

 

下一篇:没有了

发布日期:2025/3/9
手机扫二维码直达本页
发布时间:20:55:07
点  击:15
录  入:壹家怡园
相关文章
Baidu
YiJiaCMS 7.5.8 build250610(MSSQL) 闽ICP备05000814号-1
本空间由腾讯云(轻量应用服务器)提供,创宇云安全提供加速防护
运行时间载入中.....
知道创宇云安全