0
Je dois insérer les données dans une base de données MS Access de (2010) avec Asp.net (VS 2005) Veuillez vérifier le code ci-dessous. Quand je cours le code j'obtiens une erreur sur ExecuteNonQuery.Comment insérer des données dans MSAcess 2010?
Operation must use an updateable query
Public Function InsertScheme(ByVal pScheme As Scheme) As Boolean
Dim a As String = "Provider=Microsoft.ACE.OLEDB.12.0; " & _
"Data Source=C:\AAAAA.accdb;" & _
"Persist Security Info=False;"
Dim conn As OleDbConnection = New OleDbConnection(a)
'ConfigurationManager.AppSettings("connection").ToString()
conn.Open()
Dim lOledb As New OleDbCommand
lOledb.Connection = conn
lOledb.CommandType = CommandType.Text
'lOledb.CommandText = "INSERT INTO Scheme (SchemeTitle, SchemeCode, " & _
' "Details, Pre-Assesment Cost, Stage1, " & _
' "Stage1 Limit, " & _
' "S1 Premium, S1 Days Allowed, S1 deferred, " & _
' "Stage2, " & _
' "Stage2 limits, S2 Premium, S2 Days Allowed, " & _
' "S2 Deferred, Stage3, Stage3 Limit, S3 Premium, " & _
' "S3 Days Allowed, S3 Deferred, " & _
' "Monthly Finance Rate, " & _
' "Allow Financial Loss, Schedule Document, " & _
' "Policy Wording, Active) " & _
' "values ('" & pScheme.SchemeTitle & "' ,'" & _
' pScheme.SchemeCode & "' ,'" & _
' pScheme.Details & "' ,'" & _
' pScheme.PreAssesmentCost & "' ,'" & _
' pScheme.Stage1 & "' ,'" & _
' pScheme.Stage1Limit & "' ,'" & _
' pScheme.S1Premium & "' ,'" & _
' pScheme.S1DaysAllowed & "' ,'" & _
' pScheme.S1Deferred & "' ,'" & _
' pScheme.Stage2 & "' ,'" & _
' pScheme.Stage2Limit & "' ,'" & _
' pScheme.S2Premium & "' ,'" & _
' pScheme.S2DaysAllowed & "' ,'" & _
' pScheme.S2Deferred & "' ,'" & _
' pScheme.Stage3 & "' ,'" & _
' pScheme.Stage3Limit & "' ,'" & _
' pScheme.S3Premium & "' ,'" & _
' pScheme.S3DaysAllowed & "' ,'" & _
' pScheme.S3Deferred & "' ,'" & _
' pScheme.MonthlyRate & "' ,'" & _
' pScheme.AllowLoss & "' ,'" & _
' pScheme.ScheduleDocument & "' ,'" & _
' pScheme.PolicyWording & "' ,'" & _
' pScheme.Active & _
' "')"
lOledb.CommandText = "INSERT INTO Scheme " & _
"Values ('" & pScheme.SchemeTitle & "' ,'" & _
pScheme.SchemeCode & "' ,'" & _
pScheme.Details & "' ,'" & _
pScheme.PreAssesmentCost & "' ,'" & _
pScheme.Stage1 & "' ,'" & _
pScheme.Stage1Limit & "' ,'" & _
pScheme.S1Premium & "' ,'" & _
pScheme.S1DaysAllowed & "' ,'" & _
pScheme.S1Deferred & "' ,'" & _
pScheme.Stage2 & "' ,'" & _
pScheme.Stage2Limit & "' ,'" & _
pScheme.S2Premium & "' ,'" & _
pScheme.S2DaysAllowed & "' ,'" & _
pScheme.S2Deferred & "' ,'" & _
pScheme.Stage3 & "' ,'" & _
pScheme.Stage3Limit & "' ,'" & _
pScheme.S3Premium & "' ,'" & _
pScheme.S3DaysAllowed & "' ,'" & _
pScheme.S3Deferred & "' ,'" & _
pScheme.MonthlyRate & "' ,'" & _
pScheme.AllowLoss & "' ,'" & _
pScheme.ScheduleDocument & "' ,'" & _
pScheme.PolicyWording & "' ,'" & _
pScheme.Active & _
"')"
Return lOledb.ExecuteNonQuery() > 0
conn.Close()
End Function