Tag : .NET, Ms SQL Server 2008, Crystal Report, Win (Windows App), C#, VS 2008 (.NET 3.x)
ประวัติการแก้ไข 2012-04-02 15:37:51
Date :
2012-04-02 15:36:24
By :
SeedNew
View :
1365
Reply :
6
No. 1
Guest
Code (VB.NET)
sql ="select max(id) from tabelname"
cmd = New OleDbCommand(Sql, Conn)
getRecord = cmd.ExecuteScalar
for i as short = 1 to getRecord
sql = "select count(*) as cnt from tablename where id="& i
cmd = New OleDbCommand(Sql, Conn)
tempid = cmd.ExecuteScalar
if tempid = 0 then
tempid = i
exit for
end if
next
if tempid = getRecord then
NewID = getRecord +1
else
NewID = tempid
end if