public void ImageStored(Object sender,EventArgs e)
        {
            Stream imgdatastream = File1.PostedFile.InputStream;
            int imgdatalen = File1.PostedFile.ContentLength;
            string imgtype = File1.PostedFile.ContentType;
            string imgtitle = TextBox1.Text;
            byte[] imgdata = new byte[imgdatalen];
            int n = imgdatastream.Read(imgdata,0,imgdatalen);
            //string connstr="server=(local);database=ImageStore;Trusted_Connection=yes";
            SqlConnection connection = new SqlConnection(CWMis.FinanceApp.Base.strConnection);
//SqlConnection connection = new SqlConnection(connstr);
            SqlCommand command = new SqlCommand("INSERT INTO ImgStore(imgtitle,imgtype,imgdata)VALUES ( @imgtitle, @imgtype,@imgdata )", connection );
            SqlParameter paramTitle = new SqlParameter("@imgtitle", SqlDbType.VarChar,50 );
            paramTitle.Value = imgtitle;
            command.Parameters.Add( paramTitle);
            SqlParameter paramData = new SqlParameter( "@imgdata", SqlDbType.Image );
            paramData.Value = imgdata;
            command.Parameters.Add( paramData );
            SqlParameter paramType = new SqlParameter( "@imgtype", SqlDbType.VarChar,50 );
            paramType.Value = imgtype;
            command.Parameters.Add( paramType );
            connection.Open();
            int numRowsAffected = command.ExecuteNonQuery();
            connection.Close();
        }
这段代码中 我要同时把openFileDialog读取的文件的 (文件名,文件大小,文件类型,文件内容,)INSERT 到数据库中相应的表中,不过上面代码有问题 调不通,帮我看看~



 
											





 
	    

 
	


