Public Sub CustomID()
con.Open()
sql = "SELECT Max(Right(Delievery Number,4)) As Delievery Number From tbl_monitoring " '[Delievery Number] From tbl_monitoring
command = New OleDbCommand(sql, con)
reader = command.ExecuteReader
reader.Read()
If Not reader.HasRows Or IsDBNull(reader.Item("Delievery Number")) Then
txtDel.Text = "Del" & "0001"
Else
Dim Idnew As Integer = CInt(reader.Item("Delievery Number"))
Idnew += 1
txtDel.Text = "Del" & Idnew.ToString("0000")
End If
reader.Close()
End Sub
答案 0 :(得分:0)
如果你手动生成它,我首先会指出它不是自动编号。
至于问题,这是在列名中包含空格的症状。如果可能,请从' Delievery Number'更改该列的名称。到DelieveryNumber'或者,如果是英文,请使用正确的拼写并将其命名为“DeliveryNumber'。
如果您无法更改列名,则必须在SQL中将其撤消,即使用' [Delievery Number]'。