Problem with Insert statement...

  • Thread starter Thread starter Paul Mason
  • Start date Start date
P

Paul Mason

Hi folks,

The ado.net stream appears to be not working so I'm here.

The following function generates the error "Operation must use an updateable
query". There is no identifiable or meaningful error code.

This system is using OLEDB to connect to an Access database. I've tried
applying the insert statement directly to the Access database and it works
fine.

I'm not sure whether this is because the connection isn't allowing updates
or whether there's something odd about the insert statement.

Cheers...P


Public Function AddMatchReport(ByVal lngTeamMatchID As Long, ByVal
lngMemberID As Long, ByVal strReport As String) As Boolean

Dim cm As OleDb.OleDbCommand

Dim adp As OleDb.OleDbDataAdapter

Dim ds As Data.DataSet

Dim rw As DataRow

Dim strRet As String

If Me.Connection.State = ConnectionState.Closed Then

Me.Connection.Open()

End If

cm = New OleDb.OleDbCommand

cm.Connection = Me.Connection

cm.CommandText = "INSERT INTO tbTeamMatchReport (TeamMatchID, MemberID,
Report) " & _

"VALUES (" & lngTeamMatchID & ", " & lngMemberID & ", " & _

Chr(34) & strReport & Chr(34) & ")"

'cm.CommandType = CommandType.Text

If cm.ExecuteNonQuery() = -1 Then

Return True

Else

Return False

End If



End Function
 
I'm not sure whether this is because the connection isn't allowing updates
or whether there's something odd about the insert statement.

Most likely neither. In all probability the user account under which ASP.Net
is running does not have "change" permission for the folder containing the
database. Note that this refers to file system security and permissions, NOT
web server permissions.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
Back
Top