469,658 Members | 1,862 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,658 developers. It's quick & easy.

ERROR: Attempted to read or write protected memory

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

Oct 27 '06 #1
1 2248
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
"Michael" wrote:
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
Oct 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Jeff | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.