using System; using System.Data.SqlClient; using System.Data.SqlTypes; using System.IO;
string imageFileLocation=“D:\images\”; string imageFilePrefix=“cereal“; int numberImageFiles=7; string imageFileType=“.gif“; int maxImageSize=10000; SqlConnection imageConnection=null; SqlCommand imageCommand=null;]
//几个要用到的方法; void openConnection() { //create SqlConnection Object imageConnection=new SqlConnection(ConfigurationSettings.AppSettings[“wind“]); //open connection imageConnection.open(); } void closeConnection() { //close the connection
imageConnection.Close(); } void createCommand() { imageCommand=new SqlCommand(); imageCommand.Connection=imageConnection; } void executeCommand(string commandText) { int commandResult; imageCommand.CommandText=commandText; commandResult=imageCommand.ExecuteNonQuery(); } void createImageTable() { executeCommand( “IF EXISTS{“+ “SELECT TABLE_NAME“+ “FROM INFOEMATION_SCHEMA.TABLES“+ “WHERE TABLE_NAME='imagetable'“+ “) DROP TABLE imagetable“ ); executeCommand( “CREATE TABLE imagetable(“+ “imagefile NVARCHAR(20),“+ “imagedata IMAGE“+ “)“ ); }

|