Reputation: 346
I have an Excel file with a list of datas that I have to import into an Access db created by me. Inside the db I have a column named 'Description'. It can happens, when the description is more long than a cell, that I have to update my field, but I don't know how to write correctly the query.
In my Excel file the description starts from the C column, so when I want to extract the string I write a line of code like this:
cap.Description = grid(r, 3).Text
I tried to write an Update query, but it doesn't works because VS shows me this message: "additional information no value given for one or more required parameters".
Public Sub updateDB(ByVal PathDB As String)
Dim db As New cDB
Dim v As New cVoice
Dim rs As ADODB.Recordset = db.RecordSet
db.connect_DB(PathDB)
db.get_rs("UPDATE Voice SET Description = @v.Description")
db.close_DB()
End Sub
Public Function get_rs(ByVal query As String) As ADODB.Recordset
If db Is Nothing Then rs = Nothing : Return rs
rs = New ADODB.Recordset
rs.CursorType = ADODB.CursorTypeEnum.adOpenStatic
rs.LockType = ADODB.LockTypeEnum.adLockOptimistic
rs.Open(query, db)
Return rs
End Function
Public Function connect_DB() As ADODB.Connection
If Not My.Computer.FileSystem.FileExists(pPathDB) Then db = Nothing : Return db
db = New ADODB.Connection
db.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & pPathDB & ";Persist Security Info=False"
db.Open()
If db.State = ConnectionState.Closed Then db = Nothing
Return db
End Function
Then I tried to switch, stupidly, Description = @v.Description
with Description = grid(r, 3).Text
, but obviously this way doesn't work.
So, how can I express that I have to update my db column with C cell in Excel?
Upvotes: 1
Views: 300
Reputation: 191
Try to make the query as:
db.get_rs("UPDATE Voice SET Description = '" + v.Description +"'")
As this error means that there is wrong spelling for the value or missed value as mentioned here: no value given for one or more required parameters
Upvotes: 1