using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
byte[] byData = new byte[60000];
FileStream afile = new FileStream("w270.jpg", FileMode.Open, FileAccess.Read);
afile.Read(byData, 0, 60000);
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Test.mdb;Persist Security Info=False;";
string strSQL = "INSERT INTO map(byPic) VALUES(???????)";
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbCommand myCmd = new OleDbCommand(strSQL, myConn);
try
{
myConn.Open();
myCmd.ExecuteNonQuery();
}
catch (Exception q)
{
Console.WriteLine("Oooops. I did it again:\n{0}", q.Message);
}
finally
{
myConn.Close();
}
MemoryStream buf = new MemoryStream(byData);
Image image = Image.FromStream(buf,true);
pictureBox1.Image = image;
}
}
}
“?”的部分应该怎么写才能把byData二进制数组写入数据库
|