I'm trying to insert a new records into database, one of those records is a "datetime"...when I type a wrong date, and try to insert those values into database, i get an error (about wrong typed date etc.)...ok, that's fine, things need to work that way.
But here comes the problem, I correct the date, and then try to insert values again...here I get an error from the post title. And this doesn't work until I close that form and run it again...here's part of my code:
When I call my connection from that form I was talking about...
Dim cvLicence As New SQL Try cvLicence.upis("INSERT INTO blabla (itsnotimportant) VALUES ('something')") MsgBox("everything's fine", MsgBoxStyle.Information) Catch ex As Exception MsgBox("error!!!", MsgBoxStyle.Critical) MsgBox(ex.Message) End Try
and this is class/procedure i'm calling for inserting those records
Public Class SQL Public Sub upis(ByVal upit As String) myConnection.Open() Dim sq As New SqlCommand(upit, myConnection) sq.ExecuteNonQuery() myConnection.Close() End Sub Protected Overrides Sub Finalize() MyBase.Finalize() End Sub End Class
Does anyone know what could be my problem?