PTH,
The method I used to insert a file into SQL Server was using an image
field and inserting the file like a normal parameter. The code I have is
in c# but a translation to VB.net should be trivial.
BinaryReader br = null;
byte [] buffer = null;
SqlCommand cmd = new SqlCommand("InsertFileStoredProc", myConn);
cmd.CommandType = CommandType.StoredProcedure;
//Create attachment parameter
cmd.Parameters.Add("@Attachment", SqlDbType.Image);
//Put attachment into byte array
br = new BinaryReader(file.FileStream);
buffer = br.ReadBytes((int)br.BaseStream.Length);
//Set parameter values
cmd.Parameters["@Attachment"].Value = buffer;
//Insert attachment file
cmd.ExecuteNonQuery();
InsertFileStoredProc would look something like this:
CREATE PROCEDURE dbo.InsertFileStoredProc
@AttachmentFile image
AS
INSERT INTO
AttachmentFiles ( AttachmentFile)
VALUES
(@Attachment)
RETURN
There is another method you can use that splits up the file into smaller
parts but I found that it was much slower and seeing as I cannot find the
links I'll let someone else (who know's it better) describe it.
Good luck.
Wes Brown