Since the DAQ Assistant does not stop the task it creates until a true is wired into the stop terminal, the task must be stopped to change properties such as the sampling rate. You can use the DAQmx VIs to stop the task, and then change the sampling rate. The DAQ Assistant will restart the task automatically.
This can also be accomplished by using the DAQmx driver VIs exclusively. Numerous DAQmx example programs are available in LabVIEW under
Help >> Find Examples >>Hardware and Software >> DAQmx to help get started programming with DAQmx.
Additional Information
If you are trying to use this example code for a continuous acquisition, data points will be lost in between iterations of the while loop.