| | |
Save array to DB
![]() |
Choose Image/varbinary/blob/ole column (field) datatype.
Write byte array,
Read,
Write byte array,
c# Syntax (Toggle Plain Text)
byte []b=..... System.Data.OleDb.OleDbConnection cn = new System.Data.OleDb.OleDbConnection(); System.Data.OleDb.OleDbCommand cmd=new System.Data.OleDb.OleDbCommand("insert into tableName values (col1)", cn); cmd.Parameters.Add("col1",System.Data.OleDb.OleDbType.Binary,b.Length,"col1"); cmd.Parameters[0].Value= b; cn.Open(); cmd.ExecuteNonQuery(); cn.Close();
c# Syntax (Toggle Plain Text)
... cmd=new System.Data.OleDb.OleDbCommand("select * from tableName",cn); System.Data.OleDb.OleDbDataReader dr; dr=cmd.ExecuteReader(); while(dr.Read()) { byte []t=(byte [])dr[0]; .... } dr.Close();
c# Syntax (Toggle Plain Text)
[Serializable] public class Test { } class MainA { static void Main() { Test a = new Test(); System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bs = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); bs.Serialize(ms, a); byte[] b = ms.ToArray(); Console.WriteLine(b.Length); } }
![]() |
Similar Threads
- question about programing pratice with a large array (C++)
- How do I save an array variable's value even after the program has been shut? (C#)
- Assigning one array element to another array. (C++)
- 2D array memory allocation error (C++)
- Saving the array of structures (C++)
- How to load a JPEG image file, store it in array and then save it (Visual Basic 4 / 5 / 6)
- save ARRay elements to a file (C++)
- Sorting 2D Dynamic array of integers , Snake Style (C)
- bubble sorting in an array (C)
Other Threads in the C# Forum
- Previous Thread: How do i capture windows login name for windows service?
- Next Thread: GUI C#
Views: 345 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C#
.net 2d access algorithm application array asp.net assembly bitmap box button c# calculator check checkbox class code color control conversion csharp custom database datagrid datagridview dataset datetime degrees deployment display dll drawing encryption enum event excel exception expression file files flash form format forms function gcd gdi+ graphics grid image index input internet list listbox login math mdi mysql numbers operator outlook2007 photoshop php picturebox print programming property regex remote remoting resource saving search server socket sounds sql statistics stream string studio table text textbox thread threading time timer update usercontrol validation variable vc++ visual webbrowser windows winforms wpf xml






