I am connecting to the database and calling a procedure
to insert in the database but this error occurs you know the reason:
Code:
Dim con As SqlConnection = New SqlConnection()
Dim cmd As SqlCommand = New SqlCommand()
con = Nothing
cmd = Nothing
Try
con.ConnectionString = "Server = ;Database=;User Id=;Password = ;"
con.Open()
cmd.Connection = con
cmd = New SqlCommand("prdInserirRegistro", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@dtLog", SqlDbType.DateTime))
cmd.Parameters.Add(New SqlParameter("@dsLog", SqlDbType.VarChar, 1000))
'recebe o parâmetro selecionado na combobox
cmd.Parameters("@dtLog").Value = Now
cmd.Parameters("@dsLog").Value = txtBoxLog.Text
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox("erro em: " & ex.Message)
Finally
If Not con Is Nothing Then
con.Close()
con.Dispose()
End If
con = Nothing
If Not cmd Is Nothing Then
cmd.Dispose()
End If
cmd = Nothing