General information
Category:
Database DAO/RDO/ODBC/ADO
You can't mix keyset cursor with client-side location. If you check after opening the recordset, ADO changes your settings without error message. For keyset and dynamic, you must use server side location.
>>>The error message prompted was
>>> Run-time error '-2147217887(80040e21)'
>>> Errors occurred.
>>>
>>>I am pretty sure the error occurred when the assigning of a string with
>>>Comma in it, like the below example. I am try to write a string
>>>"29 Senoko Way, Singapore 123456" into the Address1 table field.
>>>But when I take out the Comma, then everything is OK.
>>>
>>>But if I were to type it manually using Access environment, it
>>>accept the Comma. Any ideas, what when wrong with my code? Thanks.
>>>
>>>>Which error?
>>>>
>>>>>Thank you very much.
>>>>>Eric, I have another issue, hope you don't mind.
>>>>> With AdodcAddRec
>>>>> With .Recordset
>>>>> .AddNew
>>>>> !Index = "A"
>>>>> !Name = "Alvin"
>>>>> !Address1 = "29 Senoko Way, Singapore 123456"
>>>>> End With
>>>>> End With
>>>>>
>>>>>I hit with error while the program write into the Table.
>>>>>The problem lies in the "Comma" in the Address1 field.
>>>>>If I take out the "Comma" then the record will be created in the
>>>>>Table. What actually went wrong, I can input the "Comma" in an
>>>>>Access environment and why not in the VB program? Pls help me.
>>>>>
>>
>>Try to set these properties on your adodc:
>>CursorLocation = adUseClient
>>CursorType = adOpenKeyset
>>LockType = adLockOptimistic
>
>I tried your suggestion, but still couldn't add record that has a Comma
>in it. My code is as follows:
>
> '(Declared Public variables for cnn1 and rsCust)
> Set cnn1 = New ADODB.Connection
> Set rsCust = New ADODB.Recordset
>
> cnn1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;
> Data Source=C:\TTDental\TTDental.mdb;Persist Security Info=False;
> Jet OLEDB:Database Password=123"
> cnn1.CursorLocation = adUseClient
> cnn1.Open
>
> rsCust.Open "Select * from customer", cnn1, adOpenKeyset, adLockOptimistic
> Set DataGrid1.DataSource = rsCust
> DataGrid1.Refresh
>
>
> 'In ADD click button, adding a record into Customer table
> With rsCust
> .AddNew
> !IndexNo = "T001"
> !Name = "Albert Tan"
> !Address1 = "29 Senoko Way, Singapore 123456"
> !Address2 = "#01-12"
> End With
>
>Am I doing the right coding? Pls advise.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only