我想要一个每年都会刷新的ID

时间:2019-03-01 18:49:03

标签: vb.net

该代码有效,但是当年份更改了固定为1个ID的编号时,我需要帮助

git stash

此插入代码:

Public con As NewOleDbConnection(
    "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Settings.ConStr & ";") 

Public Function Max_id()
    Dim mydate = Form6.DateTimePicker3.Value
    Dim myyear = Year(mydate)
    Dim n As Integer

    If myyear = Now.Year Then
        Dim cmd As New OleDbCommand("Select max(id) FROM table1", con)
        con.Open()
        Try
            n = cmd.ExecuteScalar
        Catch
            n = 0
        End Try
    End If

    If myyear > Now.Year Then
        Try
            n = cmd.ExecuteScalar
        Catch
            n = 0
        End Try
    End If

    'End If
    con.Close()
    Return n
End Function

0 个答案:

没有答案