Hello and Greetings.

I have a small problem. I am trying to save an image data to an sqlite
database table. The flow is simple. I have an imageview which holds an
image.
There is a button on clicking which the image data is supposed to be saved
to the database as binary large object.

Here is the code I am using-->

partial void SaveClick (MonoTouch.UIKit.UIButton sender)
                {
                        UIImage img=imgSource.Image;
                        NSData data=img.AsPNG ();
                        this.CreateDBConnection ();
                        using(var comm=new SqliteCommand())
                        {
                                comm.Connection=sconn;
                                comm.CommandText="insert into PhotoTBL(PhotoID, 
PhotoData) values(1,
@imagedata)";
                                comm.Parameters.Add ("@imagedata");  
<------------ this line throws
exception
                                comm.Parameters[0].Size=(int)data.Length;
                                comm.Parameters[0].Value=data.ToArray();

                                comm.ExecuteNonQuery ();

                                UIAlertView uv=new UIAlertView("Notification", 
"Image Saved To
Database!", null, "OK", null);
                                uv.Show ();
                        }
                        this.CloseDBConnection ();
                }               


But this code is throwing an exception:
*
Invalid Cast Exception: Unable to cast object of type 'System.String' to
type 'Mono.Data.Sqlite.SqliteParamater' at .......*


My PhotoData column is declared as blob. I have added all the necessary
references like Mono.Data.Sqlite, Mono.Data.Tds, System.Data etc to ensure
successful execution. Still this error persists.
I have been trying this for two days now with zero success. Some one please
help me I am really stuck with this situation. Sorry it is kind of trivial
for you, but I am really a beginner.

Kindly help me out by spotting the error. I really need some help on this
one.

Many Thanks in advance.



--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/Unable-to-Save-Image-to-Sqlite-DataBase-tp4656514.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to