none
can Sidebar gadget connect to Server side Database?

    Question

  • Hi and thanks in advance for you precious time.

    I was wondering can a gadget be coded so that  on an event the gadget will connect to a server side database and update tables.

    The application i am trying to build :
    1: Drag & drop image file (.jpg, .png etc) on the gadget
    2: OnDrop event - Upload/copy the file into a folder on the server side

    I'm planning to build the drag & drop using Javascript and then After the event, call a php page to connect to the database.

    Or must I use xmlHttprequest? If you could provide some sample code on how to connect to a database on the server and how to modify it would be really helpful.

    Thank you again
    Friday, March 16, 2007 6:14 AM

Answers

  • You can connect to server side databases through ADO, as you would do normally.  There's an example here.  You just need to change the connectionstring to whatever ODBC driver you need to use.

    To transfer a file you need to use ADO as well.  Example here.  You'll need to open the binary field in your database as a 2nd binary stream and use CopyTo to copy the data from your file stream to your field stream.

    Drag & Drop, I wrote an article here which contains example code.
    Friday, March 16, 2007 8:29 AM
  • hello.

    how about building a page that returns only the records you're after in xml (or maybe in json)? then you'd only have to use xmlhttprequest to make a remote requesto that page and handle the response.
    Friday, March 16, 2007 9:40 AM
  • hello.
    ah, ok...then how about building a web service for handling that kind of info?

    here's some info on this:

    http://en.wikipedia.org/wiki/XMLHttpRequest
    Friday, March 16, 2007 10:08 AM

All replies

  • You can connect to server side databases through ADO, as you would do normally.  There's an example here.  You just need to change the connectionstring to whatever ODBC driver you need to use.

    To transfer a file you need to use ADO as well.  Example here.  You'll need to open the binary field in your database as a 2nd binary stream and use CopyTo to copy the data from your file stream to your field stream.

    Drag & Drop, I wrote an article here which contains example code.
    Friday, March 16, 2007 8:29 AM
  • Thanks for your quick reply. It's a very good answer but I am building the database connection pages using PHP. I don't think I can use ADO to connect to the mysql database. Is there any other way?

    Am i able to connect to the db in the normal way -

    <?php
    $link
    = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    if (!
    $link) {
       die(
    'Could not connect: ' . mysql_error());
    }
    echo
    'Connected successfully';
    mysql_close($link);
    ?>

    I'm just worried that there's access restriction ... etc.


    I just tried putting in the code you wrote on Drag and drop. Is there a way to make only a portion of the gadget available to ondrop event

    eg: ------------------
         |         Drag         |         When i put in your drag drop code, it blocked out my flyout code
         |         Drop        |         Anyway around this?
         |         Area         |
         ------------------
         | flyout link(s)     |
         ------------------

        
    Friday, March 16, 2007 9:24 AM
  • hello.

    how about building a page that returns only the records you're after in xml (or maybe in json)? then you'd only have to use xmlhttprequest to make a remote requesto that page and handle the response.
    Friday, March 16, 2007 9:40 AM
  • hi Luis,

    I'm not only after the records, I also want to be able to update the database on the server side.

    But I'm curious also about this xmlhttprequest thing you mentioned. You got any links to good tutorial/explanations of it ?

    Thanks for replying
    Friday, March 16, 2007 9:46 AM
  • hello.
    ah, ok...then how about building a web service for handling that kind of info?

    here's some info on this:

    http://en.wikipedia.org/wiki/XMLHttpRequest
    Friday, March 16, 2007 10:08 AM