请帮助我和我在vb.net中的子代码 为什么自动ID会在10增加,然后在vb.net中不会增加更多
Sub autoID(ByVal firstID As String, ByVal tbl As String, ByVal tblID As String, ByVal txt As TextBox)
connect()
sql = "SELECT MAX(RIGHT([" & tblID & "],4)) AS id FROM [" & tbl & "]"
cmd = New SqlCommand(sql, conn)
reader = cmd.ExecuteReader
reader.Read()
If Not reader.HasRows Or IsDBNull(reader.Item("id")) Then
txt.Text = firstID & "0001"
Else
Dim newID As Integer = reader.Item("id")
newID += 1
txt.Text = firstID & newID.ToString("0000")
End If
conn.Close()
txt.ReadOnly = True
End Sub