日期:2014-05-19  浏览次数:20775 次

如何把图片存储到ACCESS数据库里?
然后显示出来,我用的水晶报表显示的,着急ing!!!!!!
谢谢大家,在线等!!!!!!!!!!   已经在表里添加了一条字段,ole对象类型的.

------解决方案--------------------
http://topic.csdn.net/t/20050925/14/4292611.html
------解决方案--------------------
C# 复制代码
public static void AddEmployee(
string lastName,
string firstName,
string title,
DateTime hireDate,
int reportsTo,
string photoFilePath,
string connectionString)
{
byte[] photo = GetPhoto(photoFilePath);

using (SqlConnection connection = new SqlConnection(
connectionString))

SqlCommand command = new SqlCommand(
"INSERT INTO Employees (LastName, FirstName, " +
"Title, HireDate, ReportsTo, Photo) " +
"Values(@LastName, @FirstName, @Title, " +
"@HireDate, @ReportsTo, @Photo) ", connection);

command.Parameters.Add( "@LastName ",
SqlDbType.NVarChar, 20).Value = lastName;
command.Parameters.Add( "@FirstName ",
SqlDbType.NVarChar, 10).Value = firstName;
command.Parameters.Add( "@Title ",
SqlDbType.NVarChar, 30).Value = title;
command.Parameters.Add( "@HireDate ",
SqlDbType.DateTime).Value = hireDate;
command.Parameters.Add( "@ReportsTo ",
SqlDbType.Int).Value = reportsTo;

command.Parameters.Add( "@Photo ",
SqlDbType.Image, photo.Length).Value = photo;

connection.Open();
command.ExecuteNonQuery();
}
}

public static byte[] GetPhoto(string filePath)
{
FileStream stream = new FileStream(
filePath, FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(stream);

byte[] photo = reader.ReadBytes((int)stream.Length);

reader.Close();
stream.Close();

return photo;
}


------解决方案--------------------
以二进制文件的方式存储
------解决方案--------------------
图片读成流.保存进去就可以啦...
------解决方案--------------------
http://www.cnblogs.com/webabcd/archive/2006/12/11/588600.html
------解决方案--------------------
http://dotnet.aspx.cc/article/9154bc99-df64-4e2d-b096-26c99ce464be/read.aspx
------解决方案--------------------
转换成二进制流三