1
我被嚴重卡住了一個錯誤。當我嘗試調用一個形式(frmRecipe)從Menu.vb它詳細介紹了行,其中我試圖擺脫配方表中最大的ID錯誤,這是我下面無法將「表達式」轉換爲「DBNull」類型
Function Get_Max_Id() As String
Try
Dim CMD As New SqlCommand("SELECT MAX(Recipe_ID) FROM Recipe", CONN)
CMD.CommandType = CommandType.Text
Dim dr As SqlDataReader
dr = CMD.ExecuteReader
If dr.Read Then
Return Format(Val(dr(0)).ToString + 1, "0000")
Else
Return "0001"
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
代碼Recipe_id是數據庫的Varchar
類型