alexfont
12/5/2006 6:25:00 PM
Hello,
I've post on main MSDN foruns and they forward to me this newsgroup. They
didn't help me at all to fix my problem, so I hope here, someone could give
me a tip of what I'm doing wrong.
I'm using the following code to send a binary file into MySQL database using
Odbc and VC++:
OdbcConnection ^db = gcnew
OdbcConnection("Dsn=iDigitalConnection;server=localhost;database=iDigital;uid=root");
db->Open();
FileStream ^fs;
BinaryReader ^bin;
fs = gcnew FileStream("C:\\database.dat", FileMode::Open, FileAccess::Read);
bin = gcnew BinaryReader(fs);
cli::array<unsigned char,1> ^file = bin->ReadBytes((int)fs->Length);
bin->Close();
fs->Close();
String ^queryStr = "INSERT INTO dbress (filecontent, filesize) VALUES
(@DBFileContent,@DBFileSize)";
OdbcCommand ^myCmd = gcnew OdbcCommand(queryStr, db);
myCmd->Parameters->Add("@DBFileContent", OdbcType::Binary,
file->Length)->Value = file;
myCmd->Parameters->Add("@DBFileSize", OdbcType::BigInt, 20)->Value =
file->Length;
myCmd->ExecuteNonQuery();
db->Close();
This code runs but it put NULL data into the database. It doesn't pass
"@DBFileContent" and "@DBFileSize" and replace it with the right values.
I've read for MySQL we should use '?' instead of '@' but that doesn't help
at all.
Any help in this matter???
Thanks in advance and hope here something for you soon ;),
Alexandre