Dim i As Integer
cmd.CommandText = ("SELECT Max(AccountID) FROM Accounts")
cmd.CommandType = CommandType.Text
cmd.Connection = cnn
If IsDBNull(cmd.ExecuteScalar) Then
i = AccountsDataGridView.Item(0, i).Value
AccountIDTextBox.Text = i
Else
i = cmdinsert.ExecuteScalar + 1
AccountIDTextBox.Text = i
End If
this is my code for generate the max of ACCOUNTID
i got a problem when i clicked the button generate the problem is "ExecuteScalar: Connection property has not been initialized" HOW TO GET MAX ID TO REPLACE IN ACCOUNTTEXTBOX