私はひどくエラーで立ち往生しています。Menu.vb からフォーム (frmRecipe) を呼び出そうとすると、Recipe テーブルから最大 ID を取得しようとしている行でエラーが発生します。以下に私のコードを示します。
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
データベース内のタイプです