ERROR: Attempted to read or write protected memory

G

Guest

Hi Everyone,
This is a first for me. I'm getting this error:
Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.
This happens when the dataAdapter tries to fill the dataset. This is the
only place in my code that this happens. This is the only function that this
happens. The code is below:

Private Sub Button1_Click( ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cmd As New OleDbCommand
Dim sql As String
Dim ds As New dataset
Dim da as new OleDbDataAdapter
sql = "SELECT ClientMessages.MessageId, ClientMessages.EffectiveDate,
ClientMessages.Message, ClientMessages.WhoFor,"
sql = sql & "ClientMessages.Acknowledged, PATIENT.LastName + ', ' +
PATIENT.FirstName as ClientName "
sql = sql & "FROM ClientMessages LEFT JOIN PATIENT ON
ClientMessages.PatientId = PATIENT.PatientID "
sql = sql & "Where ClientMessages.EffectiveDate <= #" &
now.ToShortDateString & "# And ClientMessages.Acknowledged = 0 "
sql = sql & "And ClientMessages.PatientId = '" & "529195929" & "' "
sql = sql & "ORDER BY ClientMessages.EffectiveDate"
cmd.CommandText = sql
cmd.CommandType = CommandType.Text
cmd.Connection = OpenConnection
da.SelectCommand = cmd
da.Fill(ds)
ifrmClientMessage = new frmClientMessage
ifrmClientMessage.rsMessage = ds
ifrmClientMessage.ShowMessage
cmd.Connection.Dispose
cmd.Dispose
da.Dispose
ds.Dispose
End Sub

Does anyone have any idea what this is. Thanks
Michael
 
G

Guest

I have found my problem. It had a small issue with the sql that I was passing
to an Access database. I would have expected an ADO.net error in this case,
but I guess not. Talk to you all later.
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top