01.
02.
sub Autogen_id()
03.
04.
dim ComTmp as new OleDbDataReader
05.
dim drTmp as string
06.
dim sqlselect as string =
""
07.
dim Tmpid as integer = 0
08.
09.
sqlselect=
"SELECT TOP 1 ID FROM Table Order By ID DESC"
10.
11.
with ComTmp
12.
13.
.Commandtype = Commandtype.Text
14.
.CommandText = sqlselect
15.
.Connection = Myconn
16.
drTmp = .ExecuteReader
17.
18.
drTmp.Read()
19.
20.
Tmpid = Cint (drTmp.Item(
"ชื่อฟิวด์ id"
)
21.
Tmpid = Tmpid + 1
22.
23.
txtid.Text = Tmpid.Tostring(
"0000"
)
24.
25.
drTmp.Close()
26.
end with
27.
28.
end sub