All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
在Asp.Net2.0中可以方便的访问配置文件web.config_[Asp.Net教程]
Asp.net直接保存文件到客户端_[Asp.Net教程]
JS的IE和Firefox兼容性汇编_JavaScript技术_编程技术
使用php作linux自动执行脚本_[PHP教程]
delphi单选框组件(TRadioButton)使用实例
最简单删除SQL,Server中所有数据的方法_mssql学习_编程技术
实用的javascript网页特效实例代码片段_JavaScript技术_编程技术
通过查询分析器对比SQL语句的执行效率_[SQL,Server教程]
如何使用SQL Server数据库查询累计值_[SQL Server教程]
关于MSSQL数据库日志满的快速解决办法_[SQL,Server教程]
Reading number is top 10 pictures
Born After 90 Beijing sports university campus flower photos3
漂亮脸蛋魔鬼身材1
Fat bird to fly
30 beautiful school beauty4
到南昌西站了3
Take you to walk into the most true north Korea rural2
你白吃了多少药
A man's favorite things16
八个盛产美女的国家2
西游日记2
Download software ranking
Tram sex maniac 2 (H) rar bag18
C#程序员参考手册
Unix video tutorial5
Boxer's Top ten classic battle1
Tram sex maniac 2 (H) rar bag4
Tram sex maniac 2 (H) rar bag6
圣殿祭司的ASP.NET.2.0.开发详解-使用C#
Red cliff
The Bermuda triangle2
美女写真2
归海一刀 published in(发表于) 2014/2/1 0:23:04 Edit(编辑)
用数据库生成不重复的流水号_[SQL,Server教程]

用数据库生成不重复的流水号_[SQL,Server教程]

用数据库生成不重复的流水号_[SQL Server教程]

'*************************************************
'函数名:getMaxOrder
'作 用:得到最大序列号
'参 数:fieldName ----在序列号表中的字段名
' tableName ----序列号所在表名
' fieldName ----在表中的字段名
'返回值:字段的最大值
'调用函数:idAdd:作用见上
'*************************************************
function getMaxOrder(fieldName,tableName,tableFileName)
dim orderNO,orderRS,testRS
set testRS=Server.CreateObject("ADODB.recordset")
set orderRS=Server.CreateObject("ADODB.recordset")
firstNO=year(date)&right(("0"&month(date)),2)
orderSQL="select * from fieldMaxValue where fieldName='"&fieldName&"'"
orderRS.open orderSQL,conn,3,2
if not orderRS.eof then
orderRS("fieldMaxValue")=orderRS("fieldMaxValue")
orderNO=orderRS("fieldMaxValue")
if left(orderNO,6)=firstNO then
orderNO=idAdd(orderNO)
else
orderNO=firstNO&"00001"
end if
else
orderRS.addnew
orderRS("fieldName")=fieldName
orderNO=firstNO&"00001"
end if
testRS.open "select max("&tableFileName&") from "&tableName&" where "&tableFileName&" like '"&firstNO&"%'",conn,1,2
if (not testRS.eof) and testRS(0).value>orderNO then
orderNO=idAdd(testRS(0).value)
end if
testRS.close
set testRS=nothing
orderRS("fieldMaxValue")=orderNO
orderRS.update
orderRS.close
set orderRS=nothing
getMaxOrder=orderNO
end function



'*************************************************
'函数名: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"
'*************************************************
Function AddOne(first)
Dim tempfirst
AddOne = first
intfirst = Asc(first)
If (intfirst >= 48 And intfirst < 57) Or (intfirst >= 65 And intfirst < 90) Or (intfirst >= 97 And intfirst < 122) Then
AddOne = Chr(intfirst + 1)
Exit Function
End If
If (intfirst = 57) Then
AddOne = "0"
Exit Function
End If
If (intfirst = 90) Then
AddOne = "A"
Exit Function
End If
If (intfirst = 122) Then
AddOne = "a"
Exit Function
End If
End Function


Function idAdd(id)
Dim fornt, back, strFind, strBackFind, idLen, tempid
if id="" or isNull(id) then
iddAdd=1
exit Function
end if
tempid = id
idLen = Len(id)
For i = 1 To idLen
fornt = Left(id, idLen - i)
back = Right(id, i - 1)
strFind = Mid(id, idLen + 1 - i, 1)
strBackFind = AddOne(strFind)
id = fornt & strBackFind & back
If strFind < strBackFind Then
Exit For
End If
If strFind > strBackFind Then
If i = idLen Then
id = id & "1"
Else
If Mid(id, idLen - i, 1) = AddOne(Mid(id, idLen - i, 1)) Then
id = fornt & strBackFind & back & "1"
Exit For
End If
End If
End If
Next
If id = tempid Then
id = id & "1"
End If
idAdd = id
End Function



'调用示例
serviceNO=getMaxOrder("serviceNO","service","serviceNO")



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


作者:tane274 来源:蓝色理想





添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.