db_update after a submit button is clicked I want to update  a "picture" field with a type of character varying, after a button is click. My customize module is already connected to it's database.

This is my form:

function myid_user_page_form(){ 

    $enrollment = array(
        'database' =&gt; 'enrollment',
        'username' =&gt; 'postgres', 
        'password' =&gt; '', 
        'host' =&gt; 'localhost', 
        'driver' =&gt; 'pgsql',
    );

    Database::addConnectionInfo('myid', 'default', $enrollment);

    $form['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; 'Save',
        '#attributes' =&gt; array(
            'id' =&gt; 'myid_save',                         
        ),
        '#submit' =&gt; array('formsave_action'),  
   );
   return $form;
}

function formsave_action($form,&amp;$form_state) {
    db_set_active('enrollment');

    $num_updated = db_update('student')
        -&gt;fields(array(
          'picture' =&gt; 'Yucks',    
        ))
        -&gt;condition('studid', '101-03043', '=')
        -&gt;execute();

    if($num_updated) {
        drupal_set_message('Successfully Saved');       
    }else{     
        drupal_set_message('Save Failed');      
    }
    db_set_active();
}


Unfortunately, nothing works. Nothing gets updated and displayed and an error saying:



My external database is SQL_ASCII compared to drupal's default database which is UTF8 encoded. Does it do something with my problem? Can someone point me to where I've been wrong? Thanks.
Although db_update should work with db_set_active in fact db_set_active is completely unnecessary in Drupal 7. Instead of db_update($table, $options) you can do Database::getConnection('default', 'enrollment')-&gt;update($table, $options); a bit more verbose but avoids changing the global state.