B
barret bonden
(VB Exoress 20005)
I get an exception on this line : ra = myCommand.ExecuteNonQuery()
{"ExecuteNonQuery requires an open and available Connection. The
connection's current state is closed."}
in this code:
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim ra As Integer
myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\t.mdb")
myCommand = New OleDbCommand("delete from main where last = 'freud'",
myConnection)
ra = myCommand.ExecuteNonQuery()
MessageBox.Show("Records Deleted" & ra)
myConnection.Close()
whereas this code works fine :
myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\t.mdb")
myCommand = New OleDbCommand("select * from main", myConnection)
Dim myReader As OleDb.OleDbDataReader
myConnection.Open()
myReader = myCommand.ExecuteReader
Do Until myReader.Read = False
MessageBox.Show(myReader("last"))
Loop
myReader.Close()
myConnection.Close()
I get an exception on this line : ra = myCommand.ExecuteNonQuery()
{"ExecuteNonQuery requires an open and available Connection. The
connection's current state is closed."}
in this code:
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim ra As Integer
myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\t.mdb")
myCommand = New OleDbCommand("delete from main where last = 'freud'",
myConnection)
ra = myCommand.ExecuteNonQuery()
MessageBox.Show("Records Deleted" & ra)
myConnection.Close()
whereas this code works fine :
myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\t.mdb")
myCommand = New OleDbCommand("select * from main", myConnection)
Dim myReader As OleDb.OleDbDataReader
myConnection.Open()
myReader = myCommand.ExecuteReader
Do Until myReader.Read = False
MessageBox.Show(myReader("last"))
Loop
myReader.Close()
myConnection.Close()