问:
Cannot find control with name: formControlName in angular reactive form
I found this problem in many questions in stackoverflow but no luck. Please help me for figuring out what I am doing wrong.

In component :

ngOnInit() {
    this.companyCreatForm = this._formBuilder.group({
      name: [null, [Validators.required, Validators.minLength(5)]],
      about: [null, [Validators.required]],
      businessType: [null, [Validators.required]],
      address: this._formBuilder.group({
        street: [],
        website: [null, [Validators.required]],
        mobile: [null, [Validators.required]],
        email: [null, [Validators.required]],
        pageId: [null, [Validators.required]],
      }),
    });
```
<p><strong>Form :</strong></p>
<pre class="lang-xml prettyprint-override"><code><form [formGroup]="companyCreatForm" (ngSubmit)="creat_company()" novalidate class="form-horizontal">
    <div class="panel panel-default" *ngIf="generalPanel">
        <div class="panel-heading">General Info</div>
        <div class="panel-body">
            <div class="form-group">
                <label for="comapny name" class="col-sm-3 control-label">Company's Name</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" placeholder="Company's Name" formControlName="name" #refName>
                    <div *ngIf="companyCreatForm.controls['name'].hasError('required') && refName.touched" class="alert alert-danger">
                        please enter name
                    </div>
                    <div *ngIf="companyCreatForm.controls['name'].hasError('minlength')" class="alert alert-danger">
                        please enter at least 5 characters
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label for="business type" class="col-sm-3 control-label">Business type</label>
                <div class="col-sm-8">
                    <select name="businessType" formControlName="businessType" class="form-control" [(ngModel)]="defaultType">

                        <option  *ngFor="let type of businessTypes" [value]="type.id">{{type.name}}</option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label for="about" class="col-sm-3 control-label">Add Company Description</label>
                <div class="col-sm-8">
                    <textarea formControlName="about" class="form-control" id="txtArea" rows="6" cols="70"></textarea>
                </div>
            </div>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-heading">Contact Info</div>
        <div class="panel-body">
            <div class="form-group">
                <label for="address" class="col-sm-3 control-label">Business Address</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" formControlName="street" placeholder="Business Address">
                </div>
            </div>

            <div class="form-group">
                <label for="website" class="col-sm-3 control-label">Website</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" formControlName="website" placeholder="website">
                </div>
            </div>

            <div class="form-group">
                <label for="telephone" class="col-sm-3 control-label">Telephone</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" formControlName="mobile" placeholder="telephone">
                </div>
            </div>

            <div class="form-group">
                <label for="email" class="col-sm-3 control-label">Email</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" formControlName="email" placeholder="email">
                </div>
            </div>

            <div class="form-group">
                <label for="page id" class="col-sm-3 control-label">Facebook Page ID</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" formControlName="pageId" placeholder="facebook page id">
                </div>
            </div>

            <div class="form-group">
                <label for="about" class="col-sm-3  control-label"></label>
                <div class="col-sm-3">

                    <!--span class="btn btn-success form-control" (click)="openGeneralPanel()">Back</span-->
                </div>
                <label for="about" class="col-sm-2  control-label"></label>
                <div class="col-sm-3">
                    <button class="btn btn-success form-control" [disabled]="companyCreatForm.invalid" (click)="openContactInfo()">Continue</button>
                </div>
            </div>
        </div>
    </div>
</form>
</code>```

Everything should be right but when I load page find error

Cannot find control with name: 'website' ,'street', 'mobile', 'email','pageId'

Full error page from browser console is like below:

```<code>CompanyCreateComponent.html:69 ERROR CONTEXT DebugContext_ {view: Object, nodeIndex: 69, nodeDef: Object, elDef: Object, elView: Object}
View_CompanyCreateComponent_0 @ CompanyCreateComponent.html:69
proxyClass @ compiler.es5.js:14091
DebugContext_.logError @ core.es5.js:13124
ErrorHandler.handleError @ core.es5.js:1149
ApplicationRef_.tick @ core.es5.js:5060
(anonymous) @ core.es5.js:4933
ZoneDelegate.invoke @ zone.js:381
onInvoke @ core.es5.js:4128
ZoneDelegate.invoke @ zone.js:380
Zone.run @ zone.js:141
NgZone.run @ core.es5.js:3996
next @ core.es5.js:4933
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.checkStable @ core.es5.js:4093
NgZone.setHasMicrotask @ core.es5.js:4177
onHasTask @ core.es5.js:4140
ZoneDelegate.hasTask @ zone.js:434
ZoneDelegate._updateTaskCount @ zone.js:454
Zone._updateTaskCount @ zone.js:278
Zone.runTask @ zone.js:198
drainMicroTaskQueue @ zone.js:574
ZoneTask.invoke @ zone.js:480
CompanyCreateComponent.html:76 ERROR Error: Cannot find control with name: 'mobile'
    at _throwError (forms.es5.js:1830)
    at setUpControl (forms.es5.js:1738)
    at FormGroupDirective.addControl (forms.es5.js:4711)
    at FormControlName._setUpControl (forms.es5.js:5299)
    at FormControlName.ngOnChanges (forms.es5.js:5217)
    at checkAndUpdateDirectiveInline (core.es5.js:10790)
    at checkAndUpdateNodeInline (core.es5.js:12216)
    at checkAndUpdateNode (core.es5.js:12155)
    at debugCheckAndUpdateNode (core.es5.js:12858)
    at debugCheckDirectivesFn (core.es5.js:12799)
View_CompanyCreateComponent_0 @ CompanyCreateComponent.html:76
proxyClass @ compiler.es5.js:14091
DebugContext_.logError @ core.es5.js:13124
ErrorHandler.handleError @ core.es5.js:1144
ApplicationRef_.tick @ core.es5.js:5060
(anonymous) @ core.es5.js:4933
ZoneDelegate.invoke @ zone.js:381
onInvoke @ core.es5.js:4128
ZoneDelegate.invoke @ zone.js:380
Zone.run @ zone.js:141
NgZone.run @ core.es5.js:3996
next @ core.es5.js:4933
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.checkStable @ core.es5.js:4093
NgZone.onLeave @ core.es5.js:4169
onInvoke @ core.es5.js:4131
ZoneDelegate.invoke @ zone.js:380
Zone.runGuarded @ zone.js:154
_loop_1 @ zone.js:640
api.microtaskDrainDone @ zone.js:649
drainMicroTaskQueue @ zone.js:582
ZoneTask.invoke @ zone.js:480
CompanyCreateComponent.html:76 ERROR CONTEXT DebugContext_ {view: Object, nodeIndex: 85, nodeDef: Object, elDef: Object, elView: Object}
View_CompanyCreateComponent_0 @ CompanyCreateComponent.html:76
proxyClass @ compiler.es5.js:14091
DebugContext_.logError @ core.es5.js:13124
ErrorHandler.handleError @ core.es5.js:1149
ApplicationRef_.tick @ core.es5.js:5060
(anonymous) @ core.es5.js:4933
ZoneDelegate.invoke @ zone.js:381
onInvoke @ core.es5.js:4128
ZoneDelegate.invoke @ zone.js:380
Zone.run @ zone.js:141
NgZone.run @ core.es5.js:3996
next @ core.es5.js:4933
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.checkStable @ core.es5.js:4093
NgZone.onLeave @ core.es5.js:4169
onInvoke @ core.es5.js:4131
ZoneDelegate.invoke @ zone.js:380
Zone.runGuarded @ zone.js:154
_loop_1 @ zone.js:640
api.microtaskDrainDone @ zone.js:649
drainMicroTaskQueue @ zone.js:582
ZoneTask.invoke @ zone.js:480
core.es5.js:1084 ERROR Error: Uncaught (in promise): Error: Cannot find control with name: 'street'
Error: Cannot find control with name: 'street'
    at _throwError (forms.es5.js:1830)
    at setUpControl (forms.es5.js:1738)
    at FormGroupDirective.addControl (forms.es5.js:4711)
    at FormControlName._setUpControl (forms.es5.js:5299)
    at FormControlName.ngOnChanges (forms.es5.js:5217)
    at checkAndUpdateDirectiveInline (core.es5.js:10790)
    at checkAndUpdateNodeInline (core.es5.js:12216)
    at checkAndUpdateNode (core.es5.js:12155)
    at debugCheckAndUpdateNode (core.es5.js:12858)
    at debugCheckDirectivesFn (core.es5.js:12799)
    at _throwError (forms.es5.js:1830)
    at setUpControl (forms.es5.js:1738)
    at FormGroupDirective.addControl (forms.es5.js:4711)
    at FormControlName._setUpControl (forms.es5.js:5299)
    at FormControlName.ngOnChanges (forms.es5.js:5217)
    at checkAndUpdateDirectiveInline (core.es5.js:10790)
    at checkAndUpdateNodeInline (core.es5.js:12216)
    at checkAndUpdateNode (core.es5.js:12155)
    at debugCheckAndUpdateNode (core.es5.js:12858)
    at debugCheckDirectivesFn (core.es5.js:12799)
    at resolvePromise (zone.js:757)
    at resolvePromise (zone.js:728)
    at zone.js:805
    at ZoneDelegate.invokeTask (zone.js:414)
    at Object.onInvokeTask (core.es5.js:4119)
    at ZoneDelegate.invokeTask (zone.js:413)
    at Zone.runTask (zone.js:181)
    at drainMicroTaskQueue (zone.js:574)
    at HTMLButtonElement.ZoneTask.invoke (zone.js:480)
defaultErrorLogger @ core.es5.js:1084
ErrorHandler.handleError @ core.es5.js:1144
next @ core.es5.js:4757
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.triggerError @ core.es5.js:4188
onHandleError @ core.es5.js:4149
ZoneDelegate.handleError @ zone.js:385
Zone.runGuarded @ zone.js:157
_loop_1 @ zone.js:640
api.microtaskDrainDone @ zone.js:649
drainMicroTaskQueue @ zone.js:582
ZoneTask.invoke @ zone.js:480
CompanyCreateComponent.html:83 ERROR Error: Cannot find control with name: 'email'
    at _throwError (forms.es5.js:1830)
    at setUpControl (forms.es5.js:1738)
    at FormGroupDirective.addControl (forms.es5.js:4711)
    at FormControlName._setUpControl (forms.es5.js:5299)
    at FormControlName.ngOnChanges (forms.es5.js:5217)
    at checkAndUpdateDirectiveInline (core.es5.js:10790)
    at checkAndUpdateNodeInline (core.es5.js:12216)
    at checkAndUpdateNode (core.es5.js:12155)
    at debugCheckAndUpdateNode (core.es5.js:12858)
    at debugCheckDirectivesFn (core.es5.js:12799)
View_CompanyCreateComponent_0 @ CompanyCreateComponent.html:83
proxyClass @ compiler.es5.js:14091
DebugContext_.logError @ core.es5.js:13124
ErrorHandler.handleError @ core.es5.js:1144
ApplicationRef_.tick @ core.es5.js:5060
(anonymous) @ core.es5.js:4933
ZoneDelegate.invoke @ zone.js:381
onInvoke @ core.es5.js:4128
ZoneDelegate.invoke @ zone.js:380
Zone.run @ zone.js:141
NgZone.run @ core.es5.js:3996
next @ core.es5.js:4933
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.checkStable @ core.es5.js:4093
NgZone.onLeave @ core.es5.js:4169
onInvokeTask @ core.es5.js:4122
ZoneDelegate.invokeTask @ zone.js:413
Zone.runTask @ zone.js:181
ZoneTask.invoke @ zone.js:476
CompanyCreateComponent.html:83 ERROR CONTEXT DebugContext_ {view: Object, nodeIndex: 101, nodeDef: Object, elDef: Object, elView: Object}
View_CompanyCreateComponent_0 @ CompanyCreateComponent.html:83
proxyClass @ compiler.es5.js:14091
DebugContext_.logError @ core.es5.js:13124
ErrorHandler.handleError @ core.es5.js:1149
ApplicationRef_.tick @ core.es5.js:5060
(anonymous) @ core.es5.js:4933
ZoneDelegate.invoke @ zone.js:381
onInvoke @ core.es5.js:4128
ZoneDelegate.invoke @ zone.js:380
Zone.run @ zone.js:141
NgZone.run @ core.es5.js:3996
next @ core.es5.js:4933
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.checkStable @ core.es5.js:4093
NgZone.onLeave @ core.es5.js:4169
onInvokeTask @ core.es5.js:4122
ZoneDelegate.invokeTask @ zone.js:413
Zone.runTask @ zone.js:181
ZoneTask.invoke @ zone.js:476
CompanyCreateComponent.html:90 ERROR Error: Cannot find control with name: 'pageId'
    at _throwError (forms.es5.js:1830)
    at setUpControl (forms.es5.js:1738)
    at FormGroupDirective.addControl (forms.es5.js:4711)
    at FormControlName._setUpControl (forms.es5.js:5299)
    at FormControlName.ngOnChanges (forms.es5.js:5217)
    at checkAndUpdateDirectiveInline (core.es5.js:10790)
    at checkAndUpdateNodeInline (core.es5.js:12216)
    at checkAndUpdateNode (core.es5.js:12155)
    at debugCheckAndUpdateNode (core.es5.js:12858)
    at debugCheckDirectivesFn (core.es5.js:12799)
</code>```

答:
I also had this error, and you helped me solve it.
If formGroup or formGroupName are not written with the good case, then the name of the control is not found.
Correct the case of formGroup or formGroupName and it is OK.</p>

Body:
I found this problem in many questions in stackoverflow but no luck. Please help me for figuring out what I am doing wrong.

In component :

ngOnInit() {
    this.companyCreatForm = this._formBuilder.group({
      name: [null, [Validators.required, Validators.minLength(5)]],
      about: [null, [Validators.required]],
      businessType: [null, [Validators.required]],
      address: this._formBuilder.group({
        street: [],
        website: [null, [Validators.required]],
        mobile: [null, [Validators.required]],
        email: [null, [Validators.required]],
        pageId: [null, [Validators.required]],
      }),
    });

Form :

<form [formGroup]="companyCreatForm" (ngSubmit)="creat_company()" novalidate class="form-horizontal">

General Info

                Company's Name

                    <input type="text" class="form-control" placeholder="Company's Name" formControlName="name" #refName>

                        please enter name

                        please enter at least 5 characters

                Business type

                    <select name="businessType" formControlName="businessType" class="form-control" [(ngModel)]="defaultType">

                        <option  *ngFor="let type of businessTypes" [value]="type.id">{{type.name}}</option>
                    </select>

                Add Company Description

                    <textarea formControlName="about" class="form-control" id="txtArea" rows="6" cols="70"></textarea>

Contact Info

                Business Address

                    <input type="text" class="form-control" formControlName="street" placeholder="Business Address">

                Website

                    <input type="text" class="form-control" formControlName="website" placeholder="website">

                Telephone

                    <input type="text" class="form-control" formControlName="mobile" placeholder="telephone">

                Email

                    <input type="text" class="form-control" formControlName="email" placeholder="email">

                Facebook Page ID

                    <input type="text" class="form-control" formControlName="pageId" placeholder="facebook page id">

                    <button class="btn btn-success form-control" [disabled]="companyCreatForm.invalid" (click)="openContactInfo()">Continue</button>

</form>

Everything should be right but when I load page find error

Cannot find control with name: 'website' ,'street', 'mobile', 'email','pageId'

Full error page from browser console is like below:

CompanyCreateComponent.html:69 ERROR CONTEXT DebugContext_ {view: Object, nodeIndex: 69, nodeDef: Object, elDef: Object, elView: Object}
View_CompanyCreateComponent_0 @ CompanyCreateComponent.html:69
proxyClass @ compiler.es5.js:14091
DebugContext_.logError @ core.es5.js:13124
ErrorHandler.handleError @ core.es5.js:1149
ApplicationRef_.tick @ core.es5.js:5060
(anonymous) @ core.es5.js:4933
ZoneDelegate.invoke @ zone.js:381
onInvoke @ core.es5.js:4128
ZoneDelegate.invoke @ zone.js:380
Zone.run @ zone.js:141
NgZone.run @ core.es5.js:3996
next @ core.es5.js:4933
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.checkStable @ core.es5.js:4093
NgZone.setHasMicrotask @ core.es5.js:4177
onHasTask @ core.es5.js:4140
ZoneDelegate.hasTask @ zone.js:434
ZoneDelegate._updateTaskCount @ zone.js:454
Zone._updateTaskCount @ zone.js:278
Zone.runTask @ zone.js:198
drainMicroTaskQueue @ zone.js:574
ZoneTask.invoke @ zone.js:480
CompanyCreateComponent.html:76 ERROR Error: Cannot find control with name: 'mobile'
    at _throwError (forms.es5.js:1830)
    at setUpControl (forms.es5.js:1738)
    at FormGroupDirective.addControl (forms.es5.js:4711)
    at FormControlName._setUpControl (forms.es5.js:5299)
    at FormControlName.ngOnChanges (forms.es5.js:5217)
    at checkAndUpdateDirectiveInline (core.es5.js:10790)
    at checkAndUpdateNodeInline (core.es5.js:12216)
    at checkAndUpdateNode (core.es5.js:12155)
    at debugCheckAndUpdateNode (core.es5.js:12858)
    at debugCheckDirectivesFn (core.es5.js:12799)
View_CompanyCreateComponent_0 @ CompanyCreateComponent.html:76
proxyClass @ compiler.es5.js:14091
DebugContext_.logError @ core.es5.js:13124
ErrorHandler.handleError @ core.es5.js:1144
ApplicationRef_.tick @ core.es5.js:5060
(anonymous) @ core.es5.js:4933
ZoneDelegate.invoke @ zone.js:381
onInvoke @ core.es5.js:4128
ZoneDelegate.invoke @ zone.js:380
Zone.run @ zone.js:141
NgZone.run @ core.es5.js:3996
next @ core.es5.js:4933
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.checkStable @ core.es5.js:4093
NgZone.onLeave @ core.es5.js:4169
onInvoke @ core.es5.js:4131
ZoneDelegate.invoke @ zone.js:380
Zone.runGuarded @ zone.js:154
_loop_1 @ zone.js:640
api.microtaskDrainDone @ zone.js:649
drainMicroTaskQueue @ zone.js:582
ZoneTask.invoke @ zone.js:480
CompanyCreateComponent.html:76 ERROR CONTEXT DebugContext_ {view: Object, nodeIndex: 85, nodeDef: Object, elDef: Object, elView: Object}
View_CompanyCreateComponent_0 @ CompanyCreateComponent.html:76
proxyClass @ compiler.es5.js:14091
DebugContext_.logError @ core.es5.js:13124
ErrorHandler.handleError @ core.es5.js:1149
ApplicationRef_.tick @ core.es5.js:5060
(anonymous) @ core.es5.js:4933
ZoneDelegate.invoke @ zone.js:381
onInvoke @ core.es5.js:4128
ZoneDelegate.invoke @ zone.js:380
Zone.run @ zone.js:141
NgZone.run @ core.es5.js:3996
next @ core.es5.js:4933
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.checkStable @ core.es5.js:4093
NgZone.onLeave @ core.es5.js:4169
onInvoke @ core.es5.js:4131
ZoneDelegate.invoke @ zone.js:380
Zone.runGuarded @ zone.js:154
_loop_1 @ zone.js:640
api.microtaskDrainDone @ zone.js:649
drainMicroTaskQueue @ zone.js:582
ZoneTask.invoke @ zone.js:480
core.es5.js:1084 ERROR Error: Uncaught (in promise): Error: Cannot find control with name: 'street'
Error: Cannot find control with name: 'street'
    at _throwError (forms.es5.js:1830)
    at setUpControl (forms.es5.js:1738)
    at FormGroupDirective.addControl (forms.es5.js:4711)
    at FormControlName._setUpControl (forms.es5.js:5299)
    at FormControlName.ngOnChanges (forms.es5.js:5217)
    at checkAndUpdateDirectiveInline (core.es5.js:10790)
    at checkAndUpdateNodeInline (core.es5.js:12216)
    at checkAndUpdateNode (core.es5.js:12155)
    at debugCheckAndUpdateNode (core.es5.js:12858)
    at debugCheckDirectivesFn (core.es5.js:12799)
    at _throwError (forms.es5.js:1830)
    at setUpControl (forms.es5.js:1738)
    at FormGroupDirective.addControl (forms.es5.js:4711)
    at FormControlName._setUpControl (forms.es5.js:5299)
    at FormControlName.ngOnChanges (forms.es5.js:5217)
    at checkAndUpdateDirectiveInline (core.es5.js:10790)
    at checkAndUpdateNodeInline (core.es5.js:12216)
    at checkAndUpdateNode (core.es5.js:12155)
    at debugCheckAndUpdateNode (core.es5.js:12858)
    at debugCheckDirectivesFn (core.es5.js:12799)
    at resolvePromise (zone.js:757)
    at resolvePromise (zone.js:728)
    at zone.js:805
    at ZoneDelegate.invokeTask (zone.js:414)
    at Object.onInvokeTask (core.es5.js:4119)
    at ZoneDelegate.invokeTask (zone.js:413)
    at Zone.runTask (zone.js:181)
    at drainMicroTaskQueue (zone.js:574)
    at HTMLButtonElement.ZoneTask.invoke (zone.js:480)
defaultErrorLogger @ core.es5.js:1084
ErrorHandler.handleError @ core.es5.js:1144
next @ core.es5.js:4757
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.triggerError @ core.es5.js:4188
onHandleError @ core.es5.js:4149
ZoneDelegate.handleError @ zone.js:385
Zone.runGuarded @ zone.js:157
_loop_1 @ zone.js:640
api.microtaskDrainDone @ zone.js:649
drainMicroTaskQueue @ zone.js:582
ZoneTask.invoke @ zone.js:480
CompanyCreateComponent.html:83 ERROR Error: Cannot find control with name: 'email'
    at _throwError (forms.es5.js:1830)
    at setUpControl (forms.es5.js:1738)
    at FormGroupDirective.addControl (forms.es5.js:4711)
    at FormControlName._setUpControl (forms.es5.js:5299)
    at FormControlName.ngOnChanges (forms.es5.js:5217)
    at checkAndUpdateDirectiveInline (core.es5.js:10790)
    at checkAndUpdateNodeInline (core.es5.js:12216)
    at checkAndUpdateNode (core.es5.js:12155)
    at debugCheckAndUpdateNode (core.es5.js:12858)
    at debugCheckDirectivesFn (core.es5.js:12799)
View_CompanyCreateComponent_0 @ CompanyCreateComponent.html:83
proxyClass @ compiler.es5.js:14091
DebugContext_.logError @ core.es5.js:13124
ErrorHandler.handleError @ core.es5.js:1144
ApplicationRef_.tick @ core.es5.js:5060
(anonymous) @ core.es5.js:4933
ZoneDelegate.invoke @ zone.js:381
onInvoke @ core.es5.js:4128
ZoneDelegate.invoke @ zone.js:380
Zone.run @ zone.js:141
NgZone.run @ core.es5.js:3996
next @ core.es5.js:4933
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.checkStable @ core.es5.js:4093
NgZone.onLeave @ core.es5.js:4169
onInvokeTask @ core.es5.js:4122
ZoneDelegate.invokeTask @ zone.js:413
Zone.runTask @ zone.js:181
ZoneTask.invoke @ zone.js:476
CompanyCreateComponent.html:83 ERROR CONTEXT DebugContext_ {view: Object, nodeIndex: 101, nodeDef: Object, elDef: Object, elView: Object}
View_CompanyCreateComponent_0 @ CompanyCreateComponent.html:83
proxyClass @ compiler.es5.js:14091
DebugContext_.logError @ core.es5.js:13124
ErrorHandler.handleError @ core.es5.js:1149
ApplicationRef_.tick @ core.es5.js:5060
(anonymous) @ core.es5.js:4933
ZoneDelegate.invoke @ zone.js:381
onInvoke @ core.es5.js:4128
ZoneDelegate.invoke @ zone.js:380
Zone.run @ zone.js:141
NgZone.run @ core.es5.js:3996
next @ core.es5.js:4933
schedulerFn @ core.es5.js:3830
SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
SafeSubscriber.next @ Subscriber.js:185
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ core.es5.js:3816
NgZone.checkStable @ core.es5.js:4093
NgZone.onLeave @ core.es5.js:4169
onInvokeTask @ core.es5.js:4122
ZoneDelegate.invokeTask @ zone.js:413
Zone.runTask @ zone.js:181
ZoneTask.invoke @ zone.js:476
CompanyCreateComponent.html:90 ERROR Error: Cannot find control with name: 'pageId'
    at _throwError (forms.es5.js:1830)
    at setUpControl (forms.es5.js:1738)
    at FormGroupDirective.addControl (forms.es5.js:4711)
    at FormControlName._setUpControl (forms.es5.js:5299)
    at FormControlName.ngOnChanges (forms.es5.js:5217)
    at checkAndUpdateDirectiveInline (core.es5.js:10790)
    at checkAndUpdateNodeInline (core.es5.js:12216)
    at checkAndUpdateNode (core.es5.js:12155)
    at debugCheckAndUpdateNode (core.es5.js:12858)
    at debugCheckDirectivesFn (core.es5.js:12799)


来源: stackexchange

问:
JqGrid problem with striping and frozen columns
I load the grid with striping and frozen columns. Loads correctly. The first line is white, the second line is gray.
When executing the sort on one of the columns, the frozen side starts in gray and the other side starts in white.

Version 4.15.6-free
How to adjust the colors?enter image description here

```

    .myAltRowClass {
    background: #E0E0E0;
    }

    jqTreeGrid - Test zebra

    listaData=[
    {"termId":51843,"module":"M","option":"W","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["D","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52192,"module":"M","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52338,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52339,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52341,"module":"B","option":"S","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52342,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52343,"module":"B","option":"D","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52344,"module":"B","option":"D","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52345,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxxs","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52346,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52347,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52348,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52349,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52340,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":51848,"module":"B","option":"B","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1","quantityFrozenFields":0,"languagesTerms":["B","B","x","y","z","w"],"languagesTips":["B","","","","",""]},
    {"termId":51841,"module":"B","option":"S","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01","quantityFrozenFields":0,"languagesTerms":["P","S","","","",""],"languagesTips":["P","","","","",""]},
    {"termId":51842,"module":"B","option":"A","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01.01","quantityFrozenFields":0,"languagesTerms":["S","A","","","",""],"languagesTips":["U","","","","",""]},
    {"termId":52011,"module":"B","option":"U","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01.01.01","quantityFrozenFields":0,"languagesTerms":["U","U","","","",""],"languagesTips":["","","","","",""]},
    {"termId":51844,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01.01.02","quantityFrozenFields":0,"languagesTerms":["P","Ps","","","",""],"languagesTips":["P","","","","",""]}];

    var colModel = [{ label:'Module', name: 'module',    width: 160, frozen: true},
    { label:'Option', name: 'option',    width: 160, frozen: true},
    { label:'Description', name: 'termDescription',    width: 160, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal !important;"' }, frozen: true},
    { label:'Strucuture', name: 'menuStructure',    width: 80},
    { label: 'termId', name: 'termId', width: 10, hidden: true },
    { label:'Pt', name: 'languagesTerms.0', width:100, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal !important;"' }, editable: false},
    { label:'Pt', name: 'languagesTips.0', width:150, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal !important;"' }, editable: false, hidden: true},
    { label:'En', name: 'languagesTerms.1', width:100, editable: false},
    { label:'En', name: 'languagesTips.1', width:150, editable: false, hidden: true},
    { label:'Tu', name: 'languagesTerms.2', width:100, editable: false},
    { label:'Tu', name: 'languagesTips.2', width:150, editable: false, hidden: true},
    { label:'Cn', name: 'languagesTerms.3', width:100, editable: false},
    { label:'Cn', name: 'languagesTips.3', width:150, editable: false, hidden: true},
    { label:'Al', name: 'languagesTerms.4', width:100, editable: false},
    { label:'Al', name: 'languagesTips.4', width:150, editable: false, hidden: true},
    { label:'Ce', name: 'languagesTerms.5', width:100, editable: false},
    { label:'Ce', name: 'languagesTips.5', width:150, editable: false, hidden: true}];

    var lastSelection ;

    jQuery(document).ready(function($) {
        jQuery('#jqGrid').jqGrid({
            datatype: "local",
            data: listaData,
            height: 300,
            width : 900,

            colModel:colModel,

            loadonce: true,
            shrinkToFit: false,
                rowNum: 500,
                scroll: 0,

                multiSort: false,

                   loadComplete: function() {
                        $("tr.jqgrow:odd").addClass('myAltRowClass');

                    }
        });

        $("#jqGrid").jqGrid("setFrozenColumns");
    });

```

Thanks

答:
You maybe need to read the docs and search this forum. This functionality is build in in jqGrid (hope in free-jqGrid it is not depreciated).You will need just to use the grid option altRows and use option altclass to use your own class.

You problem is in using two features at the same time - loadComplete and FrozenColumns.

ContentLicense: CC BY-SA 4.0

Body:
I load the grid with striping and frozen columns. Loads correctly. The first line is white, the second line is gray.
When executing the sort on one of the columns, the frozen side starts in gray and the other side starts in white.

Version 4.15.6-free
How to adjust the colors?enter image description here

    .myAltRowClass {
    background: #E0E0E0;
    }

    jqTreeGrid - Test zebra

    listaData=[
    {"termId":51843,"module":"M","option":"W","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["D","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52192,"module":"M","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52338,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52339,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52341,"module":"B","option":"S","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52342,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52343,"module":"B","option":"D","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52344,"module":"B","option":"D","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52345,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxxs","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52346,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52347,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52348,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52349,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":52340,"module":"B","option":"","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"","quantityFrozenFields":0,"languagesTerms":["","","","","",""],"languagesTips":["","","","","",""]},
    {"termId":51848,"module":"B","option":"B","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1","quantityFrozenFields":0,"languagesTerms":["B","B","x","y","z","w"],"languagesTips":["B","","","","",""]},
    {"termId":51841,"module":"B","option":"S","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01","quantityFrozenFields":0,"languagesTerms":["P","S","","","",""],"languagesTips":["P","","","","",""]},
    {"termId":51842,"module":"B","option":"A","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01.01","quantityFrozenFields":0,"languagesTerms":["S","A","","","",""],"languagesTips":["U","","","","",""]},
    {"termId":52011,"module":"B","option":"U","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01.01.01","quantityFrozenFields":0,"languagesTerms":["U","U","","","",""],"languagesTips":["","","","","",""]},
    {"termId":51844,"module":"B","option":"P","termDescription":"xxx xxx xxx xxx xxx xxx xxx","termWidth":"0","orderGrid":"0","menuStructure":"1.01.01.02","quantityFrozenFields":0,"languagesTerms":["P","Ps","","","",""],"languagesTips":["P","","","","",""]}];

    var colModel = [{ label:'Module', name: 'module',    width: 160, frozen: true},
    { label:'Option', name: 'option',    width: 160, frozen: true},
    { label:'Description', name: 'termDescription',    width: 160, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal !important;"' }, frozen: true},
    { label:'Strucuture', name: 'menuStructure',    width: 80},
    { label: 'termId', name: 'termId', width: 10, hidden: true },
    { label:'Pt', name: 'languagesTerms.0', width:100, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal !important;"' }, editable: false},
    { label:'Pt', name: 'languagesTips.0', width:150, cellattr: function (rowId, tv, rawObject, cm, rdata) { return 'style="white-space: normal !important;"' }, editable: false, hidden: true},
    { label:'En', name: 'languagesTerms.1', width:100, editable: false},
    { label:'En', name: 'languagesTips.1', width:150, editable: false, hidden: true},
    { label:'Tu', name: 'languagesTerms.2', width:100, editable: false},
    { label:'Tu', name: 'languagesTips.2', width:150, editable: false, hidden: true},
    { label:'Cn', name: 'languagesTerms.3', width:100, editable: false},
    { label:'Cn', name: 'languagesTips.3', width:150, editable: false, hidden: true},
    { label:'Al', name: 'languagesTerms.4', width:100, editable: false},
    { label:'Al', name: 'languagesTips.4', width:150, editable: false, hidden: true},
    { label:'Ce', name: 'languagesTerms.5', width:100, editable: false},
    { label:'Ce', name: 'languagesTips.5', width:150, editable: false, hidden: true}];

    var lastSelection ;

    jQuery(document).ready(function($) {
        jQuery('#jqGrid').jqGrid({
            datatype: "local",
            data: listaData,
            height: 300,
            width : 900,

            colModel:colModel,

            loadonce: true,
            shrinkToFit: false,
                rowNum: 500,
                scroll: 0,

                multiSort: false,

                   loadComplete: function() {
                        $("tr.jqgrow:odd").addClass('myAltRowClass');

                    }
        });

        $("#jqGrid").jqGrid("setFrozenColumns");
    });

Thanks


问:
Crystal Reports - (logon failed error) change the provider from OLEDBSQL to MSOLEDBSQL to support TLS 1.2 by code
I am trying to change the provider of my Crystal Reports from OLEDBSQL to MSOLEDBSQL as OLEDBSQL does not support TLS 1.2

My Code:

```<code>Private Sub ProcessReport()
    Dim crxRpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    crxRpt.Load("D:\RND\Crystal Reports - Connector\CrystallReportConvertVB\SummaryReport.rpt")

     ChangeOleDbConnectionInfo(crxRpt, "SERVER", "DBNAME", "MSOLEDBSQL", False, "USERID", "PASSWORD")
End Sub

Friend Shared Sub ChangeOleDbConnectionInfo(ByVal reportDocument As ReportDocument, ByVal server As String, ByVal database As String, ByVal oledbProvider As String, ByVal integratedSecurity As Boolean, ByVal userId As String, ByVal password As String)

    Dim boMainPropertyBag = New NameValuePairs2()
    Dim boInnerPropertyBag = New NameValuePairs2()
    boInnerPropertyBag.Add(New NameValuePair2("Application Intent", "READWRITE"))
    boInnerPropertyBag.Add(New NameValuePair2("Auto Translate", "-1"))
    boInnerPropertyBag.Add(New NameValuePair2("Connect Timeout", "15"))
    boInnerPropertyBag.Add(New NameValuePair2("Data Source", server))
    boInnerPropertyBag.Add(New NameValuePair2("DataTypeCompatibility", "0"))
    boInnerPropertyBag.Add(New NameValuePair2("General Timeout", "0"))
    boInnerPropertyBag.Add(New NameValuePair2("Initial Catalog", database))
    boInnerPropertyBag.Add(New NameValuePair2("Integrated Security", If(integratedSecurity, "True", "False")))
    boInnerPropertyBag.Add(New NameValuePair2("Locale Identifier", "1033"))
    boInnerPropertyBag.Add(New NameValuePair2("MARS Connection", "0"))
    boInnerPropertyBag.Add(New NameValuePair2("OLE DB Services", "-5"))
    boInnerPropertyBag.Add(New NameValuePair2("Provider", oledbProvider))
    boInnerPropertyBag.Add(New NameValuePair2("Tag with column collation when possible", "0"))
    boInnerPropertyBag.Add(New NameValuePair2("Trust Server Certificate", "0"))
    boInnerPropertyBag.Add(New NameValuePair2("Use DSN Default Properties", "False"))
    boInnerPropertyBag.Add(New NameValuePair2("Use Encryption for Data", "0"))

    boMainPropertyBag.Add(New NameValuePair2("Database DLL", "crdb_ado.dll"))
    boMainPropertyBag.Add(New NameValuePair2("QE_DatabaseName", database))
    boMainPropertyBag.Add(New NameValuePair2("QE_DatabaseType", "OLE DB (ADO)"))
    boMainPropertyBag.Add(New NameValuePair2("QE_LogonProperties", boInnerPropertyBag))
    boMainPropertyBag.Add(New NameValuePair2("QE_ServerDescription", server))
    boMainPropertyBag.Add(New NameValuePair2("QE_SQLDB", "True"))
    boMainPropertyBag.Add(New NameValuePair2("SSO Enabled", "False"))

    Dim conAttributes As New CrystalDecisions.Shared.DbConnectionAttributes()
    conAttributes.Collection = boMainPropertyBag

    Dim boConnectionInfo = New ConnectionInfo With {
        .Attributes = conAttributes,
        .DatabaseName = database,
        .ServerName = server
    }

    If Not integratedSecurity Then
        boConnectionInfo.UserID = userId
        boConnectionInfo.Password = password
    End If

    Dim myTables As CrystalDecisions.CrystalReports.Engine.Tables = reportDocument.Database.Tables

    For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In reportDocument.Database.Tables
        Dim myTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo = myTable.LogOnInfo
        myTableLogonInfo.ConnectionInfo.Attributes.Collection.Clear()
        myTableLogonInfo.ConnectionInfo.Attributes = boConnectionInfo.Attributes
    Next

    Dim mySections As CrystalDecisions.CrystalReports.Engine.Sections = reportDocument.ReportDefinition.Sections
    For Each mySection As CrystalDecisions.CrystalReports.Engine.Section In mySections
        Dim myReportObjects As CrystalDecisions.CrystalReports.Engine.ReportObjects = mySection.ReportObjects
        For Each myReportObject As CrystalDecisions.CrystalReports.Engine.ReportObject In myReportObjects
            If myReportObject.Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
                Dim mySubreportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject = CType(myReportObject, CrystalDecisions.CrystalReports.Engine.SubreportObject)
                Dim subReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName)
                Dim mytablessub As CrystalDecisions.CrystalReports.Engine.Tables = subReportDocument.Database.Tables
                For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In mytablessub
                    Dim myTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo = myTable.LogOnInfo
                    myTableLogonInfo.ConnectionInfo.Attributes.Collection.Clear()

                    myTableLogonInfo.ConnectionInfo.Attributes = boConnectionInfo.Attributes

                Next
            End If
        Next
    Next

    reportDocument.VerifyDatabase()

    reportDocument.SaveAs("D:\RND\Crystal Reports - Connector\CrystallReportConvertVB\CrystallReportConvertVB\Rpt-changed3.rpt")
End Sub
</code>```

Im using the following Crystal Report Versions:

I have noted the following

Calling verifyDatabase() or refresh() on the ReportDocument changes the provider property back into original.

I have tried the ApplyLogOnInfo() - Found that it only reset the username and password and not the provider. Calling this method also resets the changed provider.

Now that I've managed to change the Provider by the following code, but It always reset the provider to the original provider.

How can this be done?
Are there any workarounds for this?

Further Update

I was able to change the provider to MSOLEDBSQL in the main report by using the code suggested by Frank (With thanks) below. But still, it fails for the subreports and gives the following error.

Not supported within subreports

 Not supported within sub reports." />

Further Update (2) - on Subreport provider change
I was able to change the provider for Crystal Report Subreports by the following code.

```<code>Friend Shared Function ChangeOleDbConnectionInfoSubReports(ByVal reportDocument As ReportDocument, ByVal server As String, ByVal database As String, ByVal schema As String, ByVal oledbProvider As String, ByVal integratedSecurity As Boolean, ByVal userId As String, ByVal password As String) As ReportDocument

    Dim boInnerPropertyBag = New PropertyBag()
    boInnerPropertyBag.Add("Application Intent", "READWRITE")
    boInnerPropertyBag.Add("Auto Translate", "-1")
    boInnerPropertyBag.Add("Connect Timeout", "15")
    boInnerPropertyBag.Add("Data Source", server)
    boInnerPropertyBag.Add("DataTypeCompatibility", "0")
    boInnerPropertyBag.Add("General Timeout", "0")
    boInnerPropertyBag.Add("Initial Catalog", database)
    boInnerPropertyBag.Add("Integrated Security", If(integratedSecurity, "True", "False"))
    boInnerPropertyBag.Add("Locale Identifier", "1033")
    boInnerPropertyBag.Add("MARS Connection", "0")
    boInnerPropertyBag.Add("OLE DB Services", "-5")
    boInnerPropertyBag.Add("Provider", oledbProvider)
    boInnerPropertyBag.Add("Tag with column collation when possible", "0")
    boInnerPropertyBag.Add("Trust Server Certificate", "0")
    boInnerPropertyBag.Add("Use DSN Default Properties", "False")
    boInnerPropertyBag.Add("Use Encryption for Data", "0")
    Dim boMainPropertyBag = New PropertyBag()
    boMainPropertyBag.Add("Database DLL", "crdb_ado.dll")
    boMainPropertyBag.Add("QE_DatabaseName", database)
    boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)")
    boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag)
    boMainPropertyBag.Add("QE_ServerDescription", server)
    boMainPropertyBag.Add("QE_SQLDB", "True")
    boMainPropertyBag.Add("SSO Enabled", "False")

    Dim boConnectionInfo = New CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo With {
        .Attributes = boMainPropertyBag,
        .Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE
    }

    If Not integratedSecurity Then
        boConnectionInfo.UserName = userId
        boConnectionInfo.Password = password
    End If

    For Each subreport As ReportDocument In reportDocument.Subreports
        For Each table As CrystalDecisions.ReportAppServer.DataDefModel.Table In reportDocument.ReportClientDocument.SubreportController.GetSubreportDatabase(subreport.Name).Tables

            Dim boTable = New CrystalDecisions.ReportAppServer.DataDefModel.Table With {
                .ConnectionInfo = boConnectionInfo,
                .Name = table.Name,
                .QualifiedName = schema & "." & table.Name,
                .[Alias] = table.[Alias]
            }

            reportDocument.ReportClientDocument.SubreportController.SetTableLocation(subreport.Name, table, boTable)
        Next
    Next

    reportDocument.VerifyDatabase()
    Return reportDocument

End Function
</code>```

Lessons Learnt

Noticed that, I can not update the driver if the installed Crystal
Report Runtime does not match with the Visual studio references (I have taken the DLLs from some Nuget packages that are not official releases). I
Couldn't make the code work with Crystal Reports 10.5.3700 that I used
and I updated the runtime to 13.0.2000 (As per this article)

Crystal Reports also have tight rules with the processor architecture.
Since I'm using a 32bit version, I have set all the settings in Visual
Studio to compile the project as a 32bit app.

答:
You can replace a report's connection info programmatically by looping through the ConnectionInfos and swapping out the provider.  There's a (IMO hack-y) explanation about adding connection/driver info here which references an SAP KB that assists in writing DB logon code, but the link in the article is dead (instead, use this one - this may be more-useful for you needs).

UPDATE 2020-Jul-7 (includes subreport handling)

// Add these using's (for readability in here):
using RasTables = CrystalDecisions.ReportAppServer.DataDefModel.Tables;
using RasTable = CrystalDecisions.ReportAppServer.DataDefModel.Table;
using RasConnectionInfo = CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo;
// ...

///
/// Updates all of the tables contained within the given Crystal Report with new OLEDB connection parameters
///
/// <param name="reportDocument">A <see cref="CrystalDecisions.CrystalReports.Engine.ReportDocument"/> of the Crystal Report</param>
/// <param name="server">The new server (Data Source) to use</param>
/// <param name="database">The new database (Initial Catalog) to use</param>
/// <param name="oledbProvider">The new OLEDB provider (see remarks)</param>
/// <param name="integratedSecurity">Whether to use a trusted connection</param>
/// <param name="userId">The new user id to use</param>
/// <param name="password">The new user's password</param>
/// <remarks>Some valid values for a SQL Server OLEDB provider (note: matching vendor components must be installed)

///

///
OLEDBSQL

///
Legacy OLE DB provider for Microsoft SQL Server

///
SQLNCLI11

///
SQL Native Client v11

///
MSOLEDBSQL

///
latest OLE DB provider for Microsoft SQL Server (use this if TLS 1.0/1.1 are disabled on the SQL Server).

/// </remarks>
internal static void ChangeOleDbConnectionInfo(ReportDocument reportDocument, string server, string database,
    string oledbProvider, bool integratedSecurity, string userId, string password)
{
    // boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
    var boMainPropertyBag = new PropertyBag();
    // boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
    // In the main property bag (boMainPropertyBag)
    var boInnerPropertyBag = new PropertyBag();

    // Set the attributes for the boInnerPropertyBag
    boInnerPropertyBag.Add("Application Intent", "READWRITE");
    boInnerPropertyBag.Add("Auto Translate", "-1");
    boInnerPropertyBag.Add("Connect Timeout", "15");
    boInnerPropertyBag.Add("Data Source", server);
    boInnerPropertyBag.Add("DataTypeCompatibility", "0");
    boInnerPropertyBag.Add("General Timeout", "0");
    boInnerPropertyBag.Add("Initial Catalog", database);
    boInnerPropertyBag.Add("Integrated Security", integratedSecurity ? "True" : "False");
    boInnerPropertyBag.Add("Locale Identifier", "1033");
    boInnerPropertyBag.Add("MARS Connection", "0");
    boInnerPropertyBag.Add("OLE DB Services", "-5");
    boInnerPropertyBag.Add("Provider", oledbProvider);
    boInnerPropertyBag.Add("Tag with column collation when possible", "0");
    boInnerPropertyBag.Add("Trust Server Certificate", "0");
    boInnerPropertyBag.Add("Use DSN Default Properties", "False");
    boInnerPropertyBag.Add("Use Encryption for Data", "0");

    // Set the attributes for the boMainPropertyBag
    boMainPropertyBag.Add("Database DLL", "crdb_ado.dll");
    boMainPropertyBag.Add("QE_DatabaseName", database);
    boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)");
    // Add the QE_LogonProperties we set in the boInnerPropertyBag Object
    boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);
    boMainPropertyBag.Add("QE_ServerDescription", server);
    boMainPropertyBag.Add("QE_SQLDB", "True");
    boMainPropertyBag.Add("SSO Enabled", "False");

    // Create a new ConnectionInfo object
    var boConnectionInfo = new RasConnectionInfo
    {
        // Pass the database properties to a connection info object
        Attributes = boMainPropertyBag,
        // Set the connection kind
        Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE
    };

    if (!integratedSecurity)
    {
        boConnectionInfo.UserName = userId;
        boConnectionInfo.Password = password;
    }

    // Local function will return a copy of the given table using the provided connection info
    RasTable CreateBoTableCopy(RasTable originalTable, RasConnectionInfo connectionInfo)
    {
        // Create a new Database Table to replace the reports current table.
        return new RasTable
        {
            // Pass the connection information to the table
            ConnectionInfo = connectionInfo,

            Name = originalTable.Name,
            QualifiedName = originalTable.QualifiedName,
            Alias = originalTable.Alias
        };
    }

    var reportClientDocument = reportDocument.ReportClientDocument;

    // Get the Database Tables Collection for your report
    RasTables boTables = reportClientDocument.DatabaseController.Database.Tables;

    // For each table in the report, set the report's table location to use a newly-modified
    // copy of itself with the new connection info
    foreach (RasTable table in boTables)
    {
        reportClientDocument.DatabaseController.SetTableLocation(table, CreateBoTableCopy(table, boConnectionInfo));
    }

    // Now drop this same science on all of the subreports
    foreach (ReportDocument subreport in reportDocument.Subreports)
    {
        var subreportName = subreport.Name;
        foreach (RasTable table in reportClientDocument.SubreportController.GetSubreportDatabase(subreportName).Tables)
        {
            reportClientDocument.SubreportController.SetTableLocation(subreportName, table, CreateBoTableCopy(table, boConnectionInfo));
        }
    }

    // Verify the database after adding substituting the new table to ensure that the table
    // updates properly when adding Command tables or Stored Procedures.
    reportDocument.VerifyDatabase();
}
```
<p>Usage:</p>
<pre class="lang-cs prettyprint-override"><code>var newSqlProvider = "MSOLEDBSQL";
if (!string.IsNullOrWhiteSpace(overrideSqlProvider))
    ChangeOleDbConnectionInfo(myReportDocument, newServerName, newDatabase, newSqlProvider, false, userName, userPassword);
</code>```

Body:
I am trying to change the provider of my Crystal Reports from OLEDBSQL to MSOLEDBSQL as OLEDBSQL does not support TLS 1.2

My Code:

Private Sub ProcessReport()
    Dim crxRpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    crxRpt.Load("D:\RND\Crystal Reports - Connector\CrystallReportConvertVB\SummaryReport.rpt")

     ChangeOleDbConnectionInfo(crxRpt, "SERVER", "DBNAME", "MSOLEDBSQL", False, "USERID", "PASSWORD")
End Sub

Friend Shared Sub ChangeOleDbConnectionInfo(ByVal reportDocument As ReportDocument, ByVal server As String, ByVal database As String, ByVal oledbProvider As String, ByVal integratedSecurity As Boolean, ByVal userId As String, ByVal password As String)

    Dim boMainPropertyBag = New NameValuePairs2()
    Dim boInnerPropertyBag = New NameValuePairs2()
    boInnerPropertyBag.Add(New NameValuePair2("Application Intent", "READWRITE"))
    boInnerPropertyBag.Add(New NameValuePair2("Auto Translate", "-1"))
    boInnerPropertyBag.Add(New NameValuePair2("Connect Timeout", "15"))
    boInnerPropertyBag.Add(New NameValuePair2("Data Source", server))
    boInnerPropertyBag.Add(New NameValuePair2("DataTypeCompatibility", "0"))
    boInnerPropertyBag.Add(New NameValuePair2("General Timeout", "0"))
    boInnerPropertyBag.Add(New NameValuePair2("Initial Catalog", database))
    boInnerPropertyBag.Add(New NameValuePair2("Integrated Security", If(integratedSecurity, "True", "False")))
    boInnerPropertyBag.Add(New NameValuePair2("Locale Identifier", "1033"))
    boInnerPropertyBag.Add(New NameValuePair2("MARS Connection", "0"))
    boInnerPropertyBag.Add(New NameValuePair2("OLE DB Services", "-5"))
    boInnerPropertyBag.Add(New NameValuePair2("Provider", oledbProvider))
    boInnerPropertyBag.Add(New NameValuePair2("Tag with column collation when possible", "0"))
    boInnerPropertyBag.Add(New NameValuePair2("Trust Server Certificate", "0"))
    boInnerPropertyBag.Add(New NameValuePair2("Use DSN Default Properties", "False"))
    boInnerPropertyBag.Add(New NameValuePair2("Use Encryption for Data", "0"))

    boMainPropertyBag.Add(New NameValuePair2("Database DLL", "crdb_ado.dll"))
    boMainPropertyBag.Add(New NameValuePair2("QE_DatabaseName", database))
    boMainPropertyBag.Add(New NameValuePair2("QE_DatabaseType", "OLE DB (ADO)"))
    boMainPropertyBag.Add(New NameValuePair2("QE_LogonProperties", boInnerPropertyBag))
    boMainPropertyBag.Add(New NameValuePair2("QE_ServerDescription", server))
    boMainPropertyBag.Add(New NameValuePair2("QE_SQLDB", "True"))
    boMainPropertyBag.Add(New NameValuePair2("SSO Enabled", "False"))

    Dim conAttributes As New CrystalDecisions.Shared.DbConnectionAttributes()
    conAttributes.Collection = boMainPropertyBag

    Dim boConnectionInfo = New ConnectionInfo With {
        .Attributes = conAttributes,
        .DatabaseName = database,
        .ServerName = server
    }

    If Not integratedSecurity Then
        boConnectionInfo.UserID = userId
        boConnectionInfo.Password = password
    End If

    Dim myTables As CrystalDecisions.CrystalReports.Engine.Tables = reportDocument.Database.Tables

    For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In reportDocument.Database.Tables
        Dim myTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo = myTable.LogOnInfo
        myTableLogonInfo.ConnectionInfo.Attributes.Collection.Clear()
        myTableLogonInfo.ConnectionInfo.Attributes = boConnectionInfo.Attributes
    Next

    Dim mySections As CrystalDecisions.CrystalReports.Engine.Sections = reportDocument.ReportDefinition.Sections
    For Each mySection As CrystalDecisions.CrystalReports.Engine.Section In mySections
        Dim myReportObjects As CrystalDecisions.CrystalReports.Engine.ReportObjects = mySection.ReportObjects
        For Each myReportObject As CrystalDecisions.CrystalReports.Engine.ReportObject In myReportObjects
            If myReportObject.Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
                Dim mySubreportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject = CType(myReportObject, CrystalDecisions.CrystalReports.Engine.SubreportObject)
                Dim subReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName)
                Dim mytablessub As CrystalDecisions.CrystalReports.Engine.Tables = subReportDocument.Database.Tables
                For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In mytablessub
                    Dim myTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo = myTable.LogOnInfo
                    myTableLogonInfo.ConnectionInfo.Attributes.Collection.Clear()

                    myTableLogonInfo.ConnectionInfo.Attributes = boConnectionInfo.Attributes

                Next
            End If
        Next
    Next

    reportDocument.VerifyDatabase()

    reportDocument.SaveAs("D:\RND\Crystal Reports - Connector\CrystallReportConvertVB\CrystallReportConvertVB\Rpt-changed3.rpt")
End Sub

Im using the following Crystal Report Versions:

I have noted the following

Calling verifyDatabase() or refresh() on the ReportDocument changes the provider property back into original.

I have tried the ApplyLogOnInfo() - Found that it only reset the username and password and not the provider. Calling this method also resets the changed provider.

Now that I've managed to change the Provider by the following code, but It always reset the provider to the original provider.

How can this be done?
Are there any workarounds for this?

Further Update

I was able to change the provider to MSOLEDBSQL in the main report by using the code suggested by Frank (With thanks) below. But still, it fails for the subreports and gives the following error.

Not supported within subreports

 Not supported within sub reports." />

Further Update (2) - on Subreport provider change
I was able to change the provider for Crystal Report Subreports by the following code.

Friend Shared Function ChangeOleDbConnectionInfoSubReports(ByVal reportDocument As ReportDocument, ByVal server As String, ByVal database As String, ByVal schema As String, ByVal oledbProvider As String, ByVal integratedSecurity As Boolean, ByVal userId As String, ByVal password As String) As ReportDocument

    Dim boInnerPropertyBag = New PropertyBag()
    boInnerPropertyBag.Add("Application Intent", "READWRITE")
    boInnerPropertyBag.Add("Auto Translate", "-1")
    boInnerPropertyBag.Add("Connect Timeout", "15")
    boInnerPropertyBag.Add("Data Source", server)
    boInnerPropertyBag.Add("DataTypeCompatibility", "0")
    boInnerPropertyBag.Add("General Timeout", "0")
    boInnerPropertyBag.Add("Initial Catalog", database)
    boInnerPropertyBag.Add("Integrated Security", If(integratedSecurity, "True", "False"))
    boInnerPropertyBag.Add("Locale Identifier", "1033")
    boInnerPropertyBag.Add("MARS Connection", "0")
    boInnerPropertyBag.Add("OLE DB Services", "-5")
    boInnerPropertyBag.Add("Provider", oledbProvider)
    boInnerPropertyBag.Add("Tag with column collation when possible", "0")
    boInnerPropertyBag.Add("Trust Server Certificate", "0")
    boInnerPropertyBag.Add("Use DSN Default Properties", "False")
    boInnerPropertyBag.Add("Use Encryption for Data", "0")
    Dim boMainPropertyBag = New PropertyBag()
    boMainPropertyBag.Add("Database DLL", "crdb_ado.dll")
    boMainPropertyBag.Add("QE_DatabaseName", database)
    boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)")
    boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag)
    boMainPropertyBag.Add("QE_ServerDescription", server)
    boMainPropertyBag.Add("QE_SQLDB", "True")
    boMainPropertyBag.Add("SSO Enabled", "False")

    Dim boConnectionInfo = New CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo With {
        .Attributes = boMainPropertyBag,
        .Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE
    }

    If Not integratedSecurity Then
        boConnectionInfo.UserName = userId
        boConnectionInfo.Password = password
    End If

    For Each subreport As ReportDocument In reportDocument.Subreports
        For Each table As CrystalDecisions.ReportAppServer.DataDefModel.Table In reportDocument.ReportClientDocument.SubreportController.GetSubreportDatabase(subreport.Name).Tables

            Dim boTable = New CrystalDecisions.ReportAppServer.DataDefModel.Table With {
                .ConnectionInfo = boConnectionInfo,
                .Name = table.Name,
                .QualifiedName = schema & "." & table.Name,
                .[Alias] = table.[Alias]
            }

            reportDocument.ReportClientDocument.SubreportController.SetTableLocation(subreport.Name, table, boTable)
        Next
    Next

    reportDocument.VerifyDatabase()
    Return reportDocument

End Function

Lessons Learnt

Noticed that, I can not update the driver if the installed Crystal
Report Runtime does not match with the Visual studio references (I have taken the DLLs from some Nuget packages that are not official releases). I
Couldn't make the code work with Crystal Reports 10.5.3700 that I used
and I updated the runtime to 13.0.2000 (As per this article)

Crystal Reports also have tight rules with the processor architecture.
Since I'm using a 32bit version, I have set all the settings in Visual
Studio to compile the project as a 32bit app.

Body:
You can replace a report's connection info programmatically by looping through the ConnectionInfos and swapping out the provider.  There's a (IMO hack-y) explanation about adding connection/driver info here which references an SAP KB that assists in writing DB logon code, but the link in the article is dead (instead, use this one - this may be more-useful for you needs).

UPDATE 2020-Jul-7 (includes subreport handling)

// Add these using's (for readability in here):
using RasTables = CrystalDecisions.ReportAppServer.DataDefModel.Tables;
using RasTable = CrystalDecisions.ReportAppServer.DataDefModel.Table;
using RasConnectionInfo = CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo;
// ...

/// <summary>
/// Updates all of the tables contained within the given Crystal Report with new OLEDB connection parameters
/// </summary>
/// <param name="reportDocument">A <see cref="CrystalDecisions.CrystalReports.Engine.ReportDocument"/> of the Crystal Report</param>
/// <param name="server">The new server (Data Source) to use</param>
/// <param name="database">The new database (Initial Catalog) to use</param>
/// <param name="oledbProvider">The new OLEDB provider (see remarks)</param>
/// <param name="integratedSecurity">Whether to use a trusted connection</param>
/// <param name="userId">The new user id to use</param>
/// <param name="password">The new user&apos;s password</param>
/// <remarks>Some valid values for a SQL Server OLEDB provider (note: matching vendor components <b>must</b> be installed)<br/>
/// <p>
/// <dt>OLEDBSQL</dt>
/// <dd>Legacy OLE DB provider for Microsoft SQL Server</dd>
/// <dt>SQLNCLI11</dt>
/// <dd>SQL Native Client v11</dd>
/// <dt>MSOLEDBSQL</dt>
/// <dd>latest OLE DB provider for Microsoft SQL Server (use this if TLS 1.0/1.1 are disabled on the SQL Server).</dd>
/// </remarks>
internal static void ChangeOleDbConnectionInfo(ReportDocument reportDocument, string server, string database,
    string oledbProvider, bool integratedSecurity, string userId, string password)
{
    // boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
    var boMainPropertyBag = new PropertyBag();
    // boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
    // In the main property bag (boMainPropertyBag)
    var boInnerPropertyBag = new PropertyBag();

    // Set the attributes for the boInnerPropertyBag
    boInnerPropertyBag.Add("Application Intent", "READWRITE");
    boInnerPropertyBag.Add("Auto Translate", "-1");
    boInnerPropertyBag.Add("Connect Timeout", "15");
    boInnerPropertyBag.Add("Data Source", server);
    boInnerPropertyBag.Add("DataTypeCompatibility", "0");
    boInnerPropertyBag.Add("General Timeout", "0");
    boInnerPropertyBag.Add("Initial Catalog", database);
    boInnerPropertyBag.Add("Integrated Security", integratedSecurity ? "True" : "False");
    boInnerPropertyBag.Add("Locale Identifier", "1033");
    boInnerPropertyBag.Add("MARS Connection", "0");
    boInnerPropertyBag.Add("OLE DB Services", "-5");
    boInnerPropertyBag.Add("Provider", oledbProvider);
    boInnerPropertyBag.Add("Tag with column collation when possible", "0");
    boInnerPropertyBag.Add("Trust Server Certificate", "0");
    boInnerPropertyBag.Add("Use DSN Default Properties", "False");
    boInnerPropertyBag.Add("Use Encryption for Data", "0");

    // Set the attributes for the boMainPropertyBag
    boMainPropertyBag.Add("Database DLL", "crdb_ado.dll");
    boMainPropertyBag.Add("QE_DatabaseName", database);
    boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)");
    // Add the QE_LogonProperties we set in the boInnerPropertyBag Object
    boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);
    boMainPropertyBag.Add("QE_ServerDescription", server);
    boMainPropertyBag.Add("QE_SQLDB", "True");
    boMainPropertyBag.Add("SSO Enabled", "False");

    // Create a new ConnectionInfo object
    var boConnectionInfo = new RasConnectionInfo
    {
        // Pass the database properties to a connection info object
        Attributes = boMainPropertyBag,
        // Set the connection kind
        Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE
    };

    if (!integratedSecurity)
    {
        boConnectionInfo.UserName = userId;
        boConnectionInfo.Password = password;
    }

    // Local function will return a copy of the given table using the provided connection info
    RasTable CreateBoTableCopy(RasTable originalTable, RasConnectionInfo connectionInfo)
    {
        // Create a new Database Table to replace the reports current table.
        return new RasTable
        {
            // Pass the connection information to the table
            ConnectionInfo = connectionInfo,

            Name = originalTable.Name,
            QualifiedName = originalTable.QualifiedName,
            Alias = originalTable.Alias
        };
    }

    var reportClientDocument = reportDocument.ReportClientDocument;

    // Get the Database Tables Collection for your report
    RasTables boTables = reportClientDocument.DatabaseController.Database.Tables;

    // For each table in the report, set the report's table location to use a newly-modified
    // copy of itself with the new connection info
    foreach (RasTable table in boTables)
    {
        reportClientDocument.DatabaseController.SetTableLocation(table, CreateBoTableCopy(table, boConnectionInfo));
    }

    // Now drop this same science on all of the subreports
    foreach (ReportDocument subreport in reportDocument.Subreports)
    {
        var subreportName = subreport.Name;
        foreach (RasTable table in reportClientDocument.SubreportController.GetSubreportDatabase(subreportName).Tables)
        {
            reportClientDocument.SubreportController.SetTableLocation(subreportName, table, CreateBoTableCopy(table, boConnectionInfo));
        }
    }

    // Verify the database after adding substituting the new table to ensure that the table
    // updates properly when adding Command tables or Stored Procedures.
    reportDocument.VerifyDatabase();
}

Usage:

var newSqlProvider = "MSOLEDBSQL";
if (!string.IsNullOrWhiteSpace(overrideSqlProvider))
    ChangeOleDbConnectionInfo(myReportDocument, newServerName, newDatabase, newSqlProvider, false, userName, userPassword);


问:
email function not passing variable to view
i want to pass a variable $data to my email views but i get undefined variable.
this is the controller method </p>

```<code>public function broadcastemail(Request $request)
{
    $this->validate($request,
        [
            'subject' => 'required',
            'emailMessage' => 'required'
        ]);

     $emailMessage = $request->emailMessage;

      $data['emailMessage'] = $emailMessage;

     Mail::send('backend.user.emailMessage', $data, function($message)
    {
        $subject = request()->subject;
        $user = User::find('31');
        $email = $user->email;
        $name = $user->first_name;
        $message->to($email, $name)->subject($subject)->with('data',$data);
    });
     //Mail::to($to)->send($data);
     //send_email($to, $name, $subject, $message);

    return back()->withSuccess('Mail Sent Successfuly');
}
</code>```

<p>and this is my view </p>

```<code><p>{{$data['emailMessage']}}</p>
</code>```

答: try to use {{ $emailMessage }} instead of {{$data['emailMessage']}} in your view and use keyword for using inside the closure function of  MAIL

Body:
i want to pass a variable $data to my email views but i get undefined variable.
this is the controller method

public function broadcastemail(Request $request)
{
    $this->validate($request,
        [
            'subject' => 'required',
            'emailMessage' => 'required'
        ]);

     $emailMessage = $request->emailMessage;

      $data['emailMessage'] = $emailMessage;

     Mail::send('backend.user.emailMessage', $data, function($message)
    {
        $subject = request()->subject;
        $user = User::find('31');
        $email = $user->email;
        $name = $user->first_name;
        $message->to($email, $name)->subject($subject)->with('data',$data);
    });
     //Mail::to($to)->send($data);
     //send_email($to, $name, $subject, $message);

    return back()->withSuccess('Mail Sent Successfuly');
}

and this is my view

{{$data['emailMessage']}}


问:
Python confusion matrix
I have a problem with the evaluation of clusters result.

I have 3 lists:

```<code># 10 objects in my corpus
TOT = [1,2,3,4,5,6,7,8,9,10]

# .... clustering into k=5 clusters

# For each automatic cluster:

    # Objects with ID 2 and 8 are stored into this
    predicted = [2,8]

    # For each cluster in the ground truth:
        true = [2,4,9]

        # computes TP, FP, TN, FN
        A = set(docs_in_cluster)
        B = set(constraints)

        TP = list(A & B)
        FP = list(A - (A & B))
        TN = list((TOT - A) & (TOT - B))
        FN = list(B - A)
</code>```

My question is: Can I compute TP, FP, TN, FN for each cluster? Does it make sense?

EDIT: Reproducible code

Short story:

I'm doing NLP, I have a corpus of 9k document that I have processed with Gensim's Word2Vec, extracted the vectors, and computed a "document vector" for each document. After that, I have computed the cosine similarity between document vectors obtaining a 9k x 9k matrix.

Finally, using this matrix I have run KMeans and Hierarchical Clustering.

Let's consider the outputs from HAC with 14 clusters:

```<code>id    label
 0        1
 1        8
     ....
9k       12
</code>```

Now the problem is: How can I evaluate the quality of my clusters?
My professor have read 100 of these 9k documents and has created some 'clusters' saying: "ok this document talks about: label1" or "ok this other talks about both label2 and label3.

Notice that labels provided by my professor are completely unrelated to the clustering process, and are just a summary of the topic, but the number is the same (in this example =14).

The code

I have two dataframes, the one above from HAC clustering and the one of 100 documents from my professors, that looks like:
(with the example made before)

GT

```<code>id    label1    label2    label3    ....    label14
 5         1         0         0                 0
34         0         1         1                 0
      ...........................
</code>```

And finally, my code does this:

```<code> # since I have labels only for 100 of my 9k documents
 indexes = list(map(int, ground_truth['id'].values.tolist()))
 reduced_df = clusters.loc[clusters['id'].isin(indexes), :]

 # now reduced_df contains only the documents that have been read by my prof
 TOT = set(reduced_df['id'].values.tolist())

 for each cluster from HAC
    doc_in_this_cluster = [ .... ]

    for each cluster from GT
       doc_in_this_label = [ ... ]

        A = set(doc_in_this_cluster )
        B = set(doc_in_this_label )

        TP = list(A & B)
        FP = list(A - (A & B))
        TN = list((TOT - A) & (TOT - B))
        FN = list(B - A)
</code>```

And the code:

```<code>indexes = list(map(int, self.ground_truth['id'].values.tolist()))
    # reduce clusters_file matching only manually analyzed documents:  -------->   TOT
    reduced_df = self.clusters.loc[self.clusters['id'].isin(indexes), :]

    TOT = set(reduced_df['id'].values.tolist())

    clusters_groups = reduced_df.groupby('label')

    for label, df_group in clusters_groups:
        docs_in_cluster = df_group['id'].values.tolist()

        row = []
        for col in self.ground_truth.columns[1:]:
            constraints = list(
                map(int, self.ground_truth.loc[self.ground_truth[col] == 1, 'id'].values.tolist())
            )

            A = set(docs_in_cluster)
            B = set(constraints)

            TP = list(A & B)
            FP = list(A - (A & B))
            TN = list((TOT - A) & (TOT - B))
            FN = list(B - A)

            print(f"HAC Cluster: {label} - GT Label: {col}")
            print(TP, FP, TN, FN)
</code>```

答:
I am assuming you are trying to implement set operations. You can try the following functions to solve your case:

def setSubtract(A,B):
    C=[]
    for i in A:
        if i in B:
            pass
        else:
            C.append(i)
    return C

def setIntersection(A,B):
    C=[]
    for i in A:
        if i in B:
            C.append(i)
    return C

TOT = [1,2,3,4,5,6,7,8,9,10]
A=[1,2,3,4]
B=[2,3]
print("A&B",setIntersection(A,B))
print("TOT-B",setSubtract(TOT,B))
```

<p>Output:</p>

<pre class="lang-py prettyprint-override"><code>A&B [2, 3]
TOT-B [1, 4, 5, 6, 7, 8, 9, 10]
</code>```

Title: Python confusion matrix

Body:
I have a problem with the evaluation of clusters result.

I have 3 lists:

# 10 objects in my corpus
TOT = [1,2,3,4,5,6,7,8,9,10]

# .... clustering into k=5 clusters

# For each automatic cluster:

    # Objects with ID 2 and 8 are stored into this
    predicted = [2,8]

    # For each cluster in the ground truth:
        true = [2,4,9]

        # computes TP, FP, TN, FN
        A = set(docs_in_cluster)
        B = set(constraints)

        TP = list(A & B)
        FP = list(A - (A & B))
        TN = list((TOT - A) & (TOT - B))
        FN = list(B - A)

My question is: Can I compute TP, FP, TN, FN for each cluster? Does it make sense?

EDIT: Reproducible code

Short story:

I'm doing NLP, I have a corpus of 9k document that I have processed with Gensim's Word2Vec, extracted the vectors, and computed a "document vector" for each document. After that, I have computed the cosine similarity between document vectors obtaining a 9k x 9k matrix.

Finally, using this matrix I have run KMeans and Hierarchical Clustering.

Let's consider the outputs from HAC with 14 clusters:

id    label
 0        1
 1        8
     ....
9k       12

Now the problem is: How can I evaluate the quality of my clusters?
My professor have read 100 of these 9k documents and has created some 'clusters' saying: "ok this document talks about: label1" or "ok this other talks about both label2 and label3.

Notice that labels provided by my professor are completely unrelated to the clustering process, and are just a summary of the topic, but the number is the same (in this example =14).

The code

I have two dataframes, the one above from HAC clustering and the one of 100 documents from my professors, that looks like:
(with the example made before)

GT

id    label1    label2    label3    ....    label14
 5         1         0         0                 0
34         0         1         1                 0
      ...........................

And finally, my code does this:

 # since I have labels only for 100 of my 9k documents
 indexes = list(map(int, ground_truth['id'].values.tolist()))
 reduced_df = clusters.loc[clusters['id'].isin(indexes), :]

 # now reduced_df contains only the documents that have been read by my prof
 TOT = set(reduced_df['id'].values.tolist())

 for each cluster from HAC
    doc_in_this_cluster = [ .... ]

    for each cluster from GT
       doc_in_this_label = [ ... ]

        A = set(doc_in_this_cluster )
        B = set(doc_in_this_label )

        TP = list(A & B)
        FP = list(A - (A & B))
        TN = list((TOT - A) & (TOT - B))
        FN = list(B - A)

And the code:

indexes = list(map(int, self.ground_truth['id'].values.tolist()))
    # reduce clusters_file matching only manually analyzed documents:  -------->   TOT
    reduced_df = self.clusters.loc[self.clusters['id'].isin(indexes), :]

    TOT = set(reduced_df['id'].values.tolist())

    clusters_groups = reduced_df.groupby('label')

    for label, df_group in clusters_groups:
        docs_in_cluster = df_group['id'].values.tolist()

        row = []
        for col in self.ground_truth.columns[1:]:
            constraints = list(
                map(int, self.ground_truth.loc[self.ground_truth[col] == 1, 'id'].values.tolist())
            )

            A = set(docs_in_cluster)
            B = set(constraints)

            TP = list(A & B)
            FP = list(A - (A & B))
            TN = list((TOT - A) & (TOT - B))
            FN = list(B - A)

            print(f"HAC Cluster: {label} - GT Label: {col}")
            print(TP, FP, TN, FN)

Body:
I am assuming you are trying to implement set operations. You can try the following functions to solve your case:

def setSubtract(A,B):
    C=[]
    for i in A:
        if i in B:
            pass
        else:
            C.append(i)
    return C

def setIntersection(A,B):
    C=[]
    for i in A:
        if i in B:
            C.append(i)
    return C

TOT = [1,2,3,4,5,6,7,8,9,10]
A=[1,2,3,4]
B=[2,3]
print("A&B",setIntersection(A,B))
print("TOT-B",setSubtract(TOT,B))

Output:

A&B [2, 3]
TOT-B [1, 4, 5, 6, 7, 8, 9, 10]


问:
Objective-C, Ads on a scrollview
I'm currently using AdWhirl for my iOS app. I want to have my ads in the bottom of a scrollview. How can I achive that without Interface Builder, or can I use Interface builder?</p>

答:
no need to use interface builder for that.

what you have to do is:-
you must be adding below lines in your viewDidLoad:-

```<code>AdWhirlView *awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[self.view addSubview:awView];
</code>```

You need to change  [self.view addSubview:awView]; line to

```<code>[self.*yourscrollviewname* addSubview:awView];
</code>```

then ads will be added in your scrollview.

for repositioning them  in AdWhirlView.h file find below lines and set the coordinates according to your requirement.

```<code>#define kAdWhirlViewDefaultFrame \
                        (CGRectMake(0,50,kAdWhirlViewWidth, kAdWhirlViewHeight))
</code>```

ContentLicense: CC BY-SA 3.0

Title: Objective-C, Ads on a scrollview

Body:
no need to use interface builder for that.

what you have to do is:-
you must be adding below lines in your viewDidLoad:-

AdWhirlView *awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[self.view addSubview:awView];

You need to change  [self.view addSubview:awView]; line to

[self.*yourscrollviewname* addSubview:awView];

then ads will be added in your scrollview.

for repositioning them  in AdWhirlView.h file find below lines and set the coordinates according to your requirement.

#define kAdWhirlViewDefaultFrame \
                        (CGRectMake(0,50,kAdWhirlViewWidth, kAdWhirlViewHeight))


问:
JS Bookmarklets: Increase/decrease site's font size
I was using the code from here to enlargen sites:

var p=document.getElementsByTagName('*');

for(i=0;i<p.length;i++) {
  if(p[i].style.fontSize){
    var s=parseInt(p[i].style.fontSize.replace("px",""));
}
else {
  var s=12;
}

s+=2;
p[i].style.fontSize=s+"px"
```

But this has recently stopped working on my Chrome (Version 81.0.4044.138 (Official Build) (64-bit)). I am curious as to why, and any working alternatives.

ٍٍExplaining "stopped working": After using it, the page goes blank, and sometimes shows "14px":

答:
This article from 2ality says

Finish with undefined: If you don’t return (or finish with!) undefined, the result replaces the current web page. [Note: Webkit browsers such as Chrome and Safari never replace a page, only non-Webkit browsers such as Firefox do.]

but Chrome has changed this behavior.

Chrome now runs a code like

if (typeof bookmark_reslt === "string") {
  document.body.innerHTML = bookmark_reslt
}
```

<p>A minimal reproducible example of the bookmarklet is <code>javascript: "14px"</code></p>

<p>The easiest solution is to add <code>undefined</code> in the end of the script.</p>

<hr>

<p>Firefox executes a code like <code>document.body.innerHTML = String(bookmark_reslt)</code></p>

<pre class="lang-js prettyprint-override"><code>// examples to see how `toString` affects Bookmarklets in Firefox
javascript: a = {}; a; // <body>[object Object]</body>
javascript: a = {}; a.toString = ()=> 2; a; // <body>2</body>
</code>```

Body:
I was using the code from here to enlargen sites:

var p=document.getElementsByTagName('*');

for(i=0;i<p.length;i++) {
  if(p[i].style.fontSize){
    var s=parseInt(p[i].style.fontSize.replace("px",""));
}
else {
  var s=12;
}

s+=2;
p[i].style.fontSize=s+"px"

But this has recently stopped working on my Chrome (Version 81.0.4044.138 (Official Build) (64-bit)). I am curious as to why, and any working alternatives.

ٍٍExplaining "stopped working": After using it, the page goes blank, and sometimes shows "14px":

Body:
This article from 2ality says

Finish with undefined: If you don’t return (or finish with!) undefined, the result replaces the current web page. [Note: Webkit browsers such as Chrome and Safari never replace a page, only non-Webkit browsers such as Firefox do.]

but Chrome has changed this behavior.

Chrome now runs a code like

if (typeof bookmark_reslt === "string") {
  document.body.innerHTML = bookmark_reslt
}

A minimal reproducible example of the bookmarklet is javascript: "14px"

The easiest solution is to add undefined in the end of the script.

Firefox executes a code like document.body.innerHTML = String(bookmark_reslt)

// examples to see how `toString` affects Bookmarklets in Firefox
javascript: a = {}; a; // <body>[object Object]</body>
javascript: a = {}; a.toString = ()=> 2; a; // <body>2</body>


问:
How to transform table using complex sql query while loading data from CSV into database within a spring boot application
I have a CSV that i am loading into a spring boot application database, so that the data can be delivered by an API. After loading it into the database, I need to run some SQL on the table to create a new column so that it can be in the proper form for the API.

It is unclear to me how to run a query for a new column, such as

```<code>select
    t.*,
    cumulative
        - lag(cumulative, 1, 0) over(partition by city order by date) as difference
from mytable t
</code>```

on this table before running the API. Im relatively new to spring boot and would appreciate if someone could point me in the right direction. Ive done a lot of googling and couldn't find anything similar to this. I did see some stuff about data.sql but it sounds like that might not work.

Im wondering how people do this professionally? What is the best way to load and transform this data? It looks like Spring batch could be helpful but I would like someone to help point me down the right path.

Thank you

答:
You can create a view:

```<code>create view v_mytable as
    select t.*,
           (cumulative  -
            lag(cumulative, 1, 0) over (partition by city order by date)
           ) as difference
    from mytable t;
</code>```

You can then use v_mytable just as you would a table name in your application.

Body:
I have a CSV that i am loading into a spring boot application database, so that the data can be delivered by an API. After loading it into the database, I need to run some SQL on the table to create a new column so that it can be in the proper form for the API.

It is unclear to me how to run a query for a new column, such as

select
    t.*,
    cumulative
        - lag(cumulative, 1, 0) over(partition by city order by date) as difference
from mytable t

on this table before running the API. Im relatively new to spring boot and would appreciate if someone could point me in the right direction. Ive done a lot of googling and couldn't find anything similar to this. I did see some stuff about data.sql but it sounds like that might not work.

Im wondering how people do this professionally? What is the best way to load and transform this data? It looks like Spring batch could be helpful but I would like someone to help point me down the right path.

Thank you

Body:
You can create a view:

create view v_mytable as
    select t.*,
           (cumulative  -
            lag(cumulative, 1, 0) over (partition by city order by date)
           ) as difference
    from mytable t;

You can then use v_mytable just as you would a table name in your application.