[sqlite] Reading Blob/Writing to File in C# 2008

2009-06-17 Thread AFShin Abdollahi
When I used your code I get:  No current row

If I use: rdr.Read(); before your code, I get the same exception as before.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Reading Blob/Writing to File in C# 2008

2009-06-17 Thread AFShin Abdollahi
Hello,
I'm Using  "System.Data.SQLite" in VS 2008 C#.

I'm using DataReader to read the data.
Everything works find except the BLOB.
I want to get that Blob and Write it to a File.

Blob data is mostly Picture and Music.

Here a bit of Code:
did-> is the document id.

String cmd = String.Format("SELECT filename,content FROM documents
WHERE did={0}",did);

contentCommand = sqlconn.CreateCommand();
contentCommand.CommandText = cmd;
rdr = contentCommand.ExecuteReader();

I tried rdr.GetBytes but it give me this Error:

System.InvalidCastException was unhandled
  Message="Specified cast is not valid."
  Source="System.Data.SQLite"
  StackTrace:
   at System.Data.SQLite.SQLiteDataReader.VerifyType(Int32 i, DbType typ)
   at System.Data.SQLite.SQLiteDataReader.GetBytes(Int32 i, Int64
fieldOffset, Byte[] buffer, Int32 bufferoffset, Int32 length)
   at SDA_Viewer.Form1.btnShow_Click(Object sender, EventArgs e)
in Form1.cs:line 139
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at 
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
   at 
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)


I've read most of the mailing list archive, and any other resource on
Web, So far nothing !

Please Help,
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Reading Blob/Writing to File in C# 2008

2009-06-16 Thread Seysan
I still have that problem.

can anyone help me in right direction?
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Reading Blob/Writing to File in C# 2008

2009-06-16 Thread Joel Lucsy
Hmmm, I know I've done this before. I'll have to dig deeper and find an example.

--
Joel LucsySeysan wrote:

When I used your code I get:  No current row

If I use: rdr.Read();
before your code, I get the same exception as before.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Reading Blob/Writing to File in C# 2008

2009-06-16 Thread Seysan
When I used your code I get:  No current row

If I use: rdr.Read();
before your code, I get the same exception as before.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Reading Blob/Writing to File in C# 2008

2009-06-16 Thread AFShin Abdollahi
The rdr is:
SQLiteDataReader rdr;
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Reading Blob/Writing to File in C# 2008

2009-06-16 Thread Joel Lucsy
On Tue, Jun 16, 2009 at 6:44 PM, Seysan wrote:
> String cmd = String.Format("SELECT filename,content FROM documents
> WHERE did={0}",did);
>           contentCommand = sqlconn.CreateCommand();
>           contentCommand.CommandText = cmd;
>           rdr = contentCommand.ExecuteReader();

If rdr is a IDataReader, then it should work like:

int len = rdr.GetBytes( 0, 0, null, 0, 0 );
byte[] buf = new byte[ len ];
rdr.GetBytes( 0, 0, buf, 0, len );

-- 
Joel Lucsy
"The dinosaurs became extinct because they didn't have a space
program." -- Larry Niven
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Reading Blob/Writing to File in C# 2008

2009-06-16 Thread Joel Lucsy
On Tue, Jun 16, 2009 at 6:44 PM, Seysan wrote:
> String cmd = String.Format("SELECT filename,content FROM documents
> WHERE did={0}",did);
>           rdr = contentCommand.ExecuteReader();

What type is rdr? I believe it should be byte[]

-- 
Joel Lucsy
"The dinosaurs became extinct because they didn't have a space
program." -- Larry Niven
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Reading Blob/Writing to File in C# 2008

2009-06-16 Thread Seysan
Hello,
I'm Using  "System.Data.SQLite" in VS 2008 C#.

I'm using DataReader to read the data.
Everything works find except the BLOB.
I want to get that Blob and Write it to a File.

Blob data is mostly Picture and Music.

Here a bit of Code:
did-> is the document id.

String cmd = String.Format("SELECT filename,content FROM documents
WHERE did={0}",did);

   contentCommand = sqlconn.CreateCommand();
   contentCommand.CommandText = cmd;
   rdr = contentCommand.ExecuteReader();

I tried rdr.GetBytes but it give me this Error:

System.InvalidCastException was unhandled
 Message="Specified cast is not valid."
 Source="System.Data.SQLite"
 StackTrace:
  at System.Data.SQLite.SQLiteDataReader.VerifyType(Int32 i, DbType typ)
  at System.Data.SQLite.SQLiteDataReader.GetBytes(Int32 i, Int64
fieldOffset, Byte[] buffer, Int32 bufferoffset, Int32 length)
  at SDA_Viewer.Form1.btnShow_Click(Object sender, EventArgs e)
in Form1.cs:line 139
  at System.Windows.Forms.Control.OnClick(EventArgs e)
  at System.Windows.Forms.Button.OnClick(EventArgs e)
  at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
  at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
  at System.Windows.Forms.Control.WndProc(Message& m)
  at System.Windows.Forms.ButtonBase.WndProc(Message& m)
  at System.Windows.Forms.Button.WndProc(Message& m)
  at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&
m)
  at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
  at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
  at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
  at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
  at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)


I've read most of the mailing list archive, and any other resource on
Web, So far nothing !

Please Help,
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users