部分文字列化で奇妙な問題が発生しています。どうやら私が得た文字列は、奇妙な理由で Int32 にキャストできません。これを実行しようとすると、「入力文字列の形式が正しくありません」というエラー メッセージが表示されます。このため、これらの値をデータベースに挿入することもできません。
これがコードです...
string width = GetMetadata(filename, 162); //returns "1280 pixels"
string height = GetMetadata(filename, 164); //returns "700 pixels"
width = width.Substring(0, width.IndexOf(' ')); //returns "1280"
height = height.Substring(0, height.IndexOf(' ')); //returns "700"
//test: "System.Convert.ToInt32(width)" will fail, giving error "input string was not in correct format"
//doing the above on "width" yields the same result
//fails, giving error "no such column: 1280" (underlying database is sqlite)
Database.NonQuery("INSERT INTO image VALUES (" + fileid + ", " + width + ", " + height + ")");