ntext、text 和 image
用于存储大型非 Unicode 字符、Unicode 字符及二进制数据的固定长度和可变长度数据类型。Unicode 数据使用 UNICODE UCS-2 字符集。ntext可变长度 Unicode 数据的最大长度为 230 - 1 (1,073,741,823) 个字符。存储大小是所输入字符个数的两倍(以字节为单位)。ntext 在 SQL-92 中的同义词是 national text。text服务器代码页中的可变长度非 Unicode 数据的最大长度为 231-1 (2,147,483,647) 个字符。当服务器代码页使用双字节字符时,存储量仍是 2,147,483,647 字节。存储大小可能小于 2,147,483,647 字节(取决于字符串)。image可变长度二进制数据介于 0 与 231-1 (2,147,483,647) 字节之间。
用于存储大型非 Unicode 字符、Unicode 字符及二进制数据的固定长度和可变长度数据类型。Unicode 数据使用 UNICODE UCS-2 字符集。ntext可变长度 Unicode 数据的最大长度为 230 - 1 (1,073,741,823) 个字符。存储大小是所输入字符个数的两倍(以字节为单位)。ntext 在 SQL-92 中的同义词是 national text。text服务器代码页中的可变长度非 Unicode 数据的最大长度为 231-1 (2,147,483,647) 个字符。当服务器代码页使用双字节字符时,存储量仍是 2,147,483,647 字节。存储大小可能小于 2,147,483,647 字节(取决于字符串)。image可变长度二进制数据介于 0 与 231-1 (2,147,483,647) 字节之间。
在access下,有个ole类型,我现在是想在access下定义一个ole类型,该用什么好?
把图片存入SQL中的主要代码:
publice string constr;//constr为数据库连接字符串
private string sqlstr;//sql字符串
private openFileDialog ofd;
private byte[] b;
private Bitmap image;
private pictureBox pictureBox1;ofd=new openFileDialog();
FileStream fs=new FileStream(ofd.FileName,FileMode.Open,FileAccess.Read);
image=new Bitmap(fs);
pictureBox1.Image=(Image)image;
b=new byte[fs.Length];
fs.Read(b,0,b.Length);
try{
SqlConnection conn=new SqlConnection(constr);
conn.open();
sqlstr=@"insert into table(photo) values(@photo)";
SqlCommand comm=new SqlCommand(conn,sqlstr);
comm.Parameters.Add("@photo",SqlDbType.Image,"photo");
comm.Parameters["@photo"].Value=b
}
catch(Exception)
{
comm.ExecteNonQuery();
}
conn.Close();
--image類型是二進制數據類型,最大能存2,147,483,647個字元--大約2G