I've converted an access DB to an SQL express DB using the built in upsizing wizard in MS access. But I now get an error when I try to programmatically add a record to the SQL server table:
Critical Error #-2147217887 Multiple-step OLE DB operation generated errors.
The field that this fails on is when I'm setting the SQL Field [notes]. I'm trying to set it to a vbnullstring (using VB6).
The access upsizing wizard created the field as a nvarchar(255) and all nulls to true, it originally was a text field with a length of 255 in ms access.
Is there a problem setting a nvarchar field in sql to a vbnullstring?
Any suggestions on what could be going wrong would be greatly appreciated!
Set RS = OpenRecordsetSQL("SELECT TOP 1 * FROM AvailabilityBlocks WHERE BlockID=-1")
' ' Add a specific entry to the Availability DB Table '
RS.AddNew
RS("Begin") = wblock.BeginTime
RS("Type") = wblock.BlockType
RS("OCampus") = wblock.Campus
RS("End") = wblock.EndTime
RS("LocationID") = wblock.LocationID
RS("ResourceID") = wblock.ResourceID
RS("RecurringSetNumber") = wblock.RWWSetNumber
RS("Notes") = wblock.Notes
RS("InternalNotes") = wblock.InternalNotes
RS.Update
You should be using Null rather than vbNullString. vbNullString is a constant designed to be used when passing data to APIs. Null is the VB representation of a null value. NULL in the database sense.
One issue you have is that in VB a String cannot be Null. You can of course use VB's variant datatype so declare Notes as
Notes as Variant
Then either
wblock.Notes = "some text"
or
wblock = Null
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.