在SQL2k中设计表时定义字段: 列名=Picture;
数据类型=image. 保存表名为dbPhoto
在BCB中,在[ADO]控件面版拖个ADOConnection1下来,填属性ADOConnection1->ConnectiuonString = Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=你的数据库名
ADOConnection1->LoginPrompt = false;
ADOConnection1->Connected = true;
再拖个ADOTable1下来,填属性ADOTable1->Connection = ADOConnection1;
ADOTable1->TableName = dbphoto;
ADOTable1->Active = true;
双击设计页面的ADOTable1,在出来的字段框中右击,选菜单的[add all fields],一个名为Picture的SQL图象字段对象就有了
保存图象:在你的程序里写:
dbPhoto.Edit ;
dbPhotoPicture.LoadFromFile(FileName) ;
dbPhoto.Post ;
显示:
在[Data Access]控件面版拖个DataSource1下来,填属性DataSource1->DataSet = ADOTable1;
在[Data Controls]控件面版拖个DBImage1下来,填属性DBImage1->DataSource = DataSource1;
DBImage1->DataField = Picture