Problems inserting: to fields: imageID and imageData.

run: ./mainprogram "file" "full_file_path" "imageID"

Her is my code:

 try {
    
con.real_connect(MY_DATABASE,MY_HOST,MY_USER,MY_PASSWORD,3306,(int)0,60,NULL);
    Query query = con.query();
    ostrstream strbuf;
    ifstream In(argv[1], ios::in | ios::binary);
    struct stat for_len;
    if (In.rdbuf()->is_open())
    {
      if (stat(argv[1], &for_len)==-1)
         return -1;
      unsigned int blen = for_len.st_size;
      if (!blen)
         return -1;
      char *read_buffer = new char[blen];
      In.read(read_buffer,blen);
      string fill(read_buffer,blen);
      strbuf << "INSERT INTO " << MY_TABLE << "values(" << argv[2] << 
",\""<<escape<<fill<<"\")";
      query.exec(strbuf.str());
      //strbuf2 << "update" << MY_TABLE << "set image_id=2";
      //query.exec(strbuf2.str());
      delete[] read_buffer;
    }
    else
    {
    cerr << "Your binary file " << argv[1] << "can not open, errno = "        
          << errno;
    }
return 0;

  }catch (BadQuery er)
   {
    cerr << "Error: " << er.error << " " << con.errnum() << endl;
    return -1;
   }


Any help here?

/jarle


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to