1
오류가 잘못되었습니다. 내가 폼 그것은 내가 레시피 테이블의 최대 ID를 얻을 노력하고 있어요 라인에 오류가 있습니다 Menu.vb에서 (frmRecipe)를 호출 할 때, 여기에'표현식'인수를 "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
의 유형입니다