Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim cell As TableCell = e.Row.Cells(4)
Dim cell2 As TableCell = e.Row.Cells(6)
Dim mytxtboxdepart As TextBox = e.Row.FindControl("txtBoxDeparture")
Dim mytxtboxstays As TextBox = e.Row.FindControl("txtBoxStays")
Dim mytxtboxcriteria As TextBox = e.Row.FindControl("txtBoxCriteria")
Dim provider As String
Dim connString As String
Dim myconnection As OleDbConnection = New OleDbConnection
provider = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("~/App_Data/myDB.mdb")
connString = provider
myconnection.ConnectionString = connString
If Convert.ToDateTime(mytxtboxdepart.Text) < Convert.ToDateTime(mytxtboxstays.Text) Then
myconnection.Open()
Response.Write(Convert.ToDateTime(mytxtboxdepart.Text))
cell2.BackColor = Color.Red
Dim str As String
str = "DELETE * FROM ReservationTb WHERE Criteria" = "5"
End If
command.Connection = myAccessConnection
command.ExecuteNonQuery()
myAccessConnection.Close()
End If
End Sub
But i am getting the error ...
ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.
PLS HELPPPPPP !!! EXPERTS