S
Shapper
Hello,
I am trying to insert a record in an Access database using
Asp.Net/Vb.Net.
I am getting the error: "Operation must use an updateable query."
How can I solve this problem?
The code I am using is:
' Set Connection
Dim connectionString As String = AppSettings("connectionString")
Dim dbConnection As IDbConnection = New
OleDbConnection(connectionString)
' Set Query
Dim queryString As String = "INSERT INTO [t_news] ([title_pt-PT],
[title_en-GB], [text_pt-PT], [text_en-GB], [publication_date]) VALUES
(@title_ptPT, @title_enGB, @text_ptPT, @text_enGB, @publication_date)"
' Set Command
Dim dbCommand As IDbCommand = New OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
' Add Parameters
With dbCommand.Parameters
.Add(New OleDbParameter("@title_ptPT", "title PT"))
.Add(New OleDbParameter("@title_enGB", "title GB"))
.Add(New OleDbParameter("@text_ptPT", "text PT"))
.Add(New OleDbParameter("@text_enGB", "text GB"))
.Add(New OleDbParameter("@publication_date",
DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss")))
End With
' Insert New Record
dbConnection.Open()
Try
dbCommand.ExecuteNonQuery()
Finally
dbConnection.Close()
End Try
Thank You,
Miguel
I am trying to insert a record in an Access database using
Asp.Net/Vb.Net.
I am getting the error: "Operation must use an updateable query."
How can I solve this problem?
The code I am using is:
' Set Connection
Dim connectionString As String = AppSettings("connectionString")
Dim dbConnection As IDbConnection = New
OleDbConnection(connectionString)
' Set Query
Dim queryString As String = "INSERT INTO [t_news] ([title_pt-PT],
[title_en-GB], [text_pt-PT], [text_en-GB], [publication_date]) VALUES
(@title_ptPT, @title_enGB, @text_ptPT, @text_enGB, @publication_date)"
' Set Command
Dim dbCommand As IDbCommand = New OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
' Add Parameters
With dbCommand.Parameters
.Add(New OleDbParameter("@title_ptPT", "title PT"))
.Add(New OleDbParameter("@title_enGB", "title GB"))
.Add(New OleDbParameter("@text_ptPT", "text PT"))
.Add(New OleDbParameter("@text_enGB", "text GB"))
.Add(New OleDbParameter("@publication_date",
DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss")))
End With
' Insert New Record
dbConnection.Open()
Try
dbCommand.ExecuteNonQuery()
Finally
dbConnection.Close()
End Try
Thank You,
Miguel