Private Sub Default__Load(ByVal Sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As SqlConnection = New SqlConnection("datasource=xxx;database=xxx;uid=xxx;pwd=xxx;")
Dim cmd As SqlCommand = New SqlCommand("SELECT ID FROM Table WHERE DateTimeCreated = ???????????", conn)
conn.Open()
Dim ID As String = Convert.ToString(cmd.ExecuteScalar())
conn.Close()
lblID.Text = ID
End Sub
基本上我需要一些东西来取代????????带来最近创建的ID(ID是uniqueidentifier)
我确信这很简单,不过我可能会把整件事搞错了。
答案 0 :(得分:2)
你应该在那里使用这样的东西来获得最新的ID
(SELECT TOP 1 ID FROM table
ORDER BY DateTimeCreated DESC)
取代你的?????当然。
EDITED