absalom60
April 14th, 2008, 12:48 PM
I am attempting to set up the IFILTER for SQL 2005 and according to the manual
you should be able to set up a web page via the code below. however I have not been able to get this to work correctly -- has anyone been successful in doing this?
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
public void OnUpload(Object sender, EventArgs e)
{
//Create a byte[] from input file
int len = File1.PostedFile.ContentLength;
byte[] PdfText=new byte[len];
File1.PostedFile.InputStream.Read(PDFText, 0, len);
//Insert the Image and Comment into the database
SQLConnection connection = new
SQLConnection(@"server=xxxx;database=Sxxxx;uid=xx;pwd=xxxx");
try
{
connection.Open();
SQLCommand cmd = new SqlCommand("insert into pdf" + "(PdfText, PdfId, Ext) values (@PdfText, @PdfId, @Ext)",connection);
//insert values into three colums.
cmd.Parameters.Add("@PdfText", PdfText);
cmd.Parameters.Add("@Pdfid". 1);//Only upload 1 PDF at a time
cmd.Parameters.Add("@Ext", ".pdf");
cmd.ExecuteNonQuery();
}
finally
{
Connection.Close();
}
}
you should be able to set up a web page via the code below. however I have not been able to get this to work correctly -- has anyone been successful in doing this?
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
public void OnUpload(Object sender, EventArgs e)
{
//Create a byte[] from input file
int len = File1.PostedFile.ContentLength;
byte[] PdfText=new byte[len];
File1.PostedFile.InputStream.Read(PDFText, 0, len);
//Insert the Image and Comment into the database
SQLConnection connection = new
SQLConnection(@"server=xxxx;database=Sxxxx;uid=xx;pwd=xxxx");
try
{
connection.Open();
SQLCommand cmd = new SqlCommand("insert into pdf" + "(PdfText, PdfId, Ext) values (@PdfText, @PdfId, @Ext)",connection);
//insert values into three colums.
cmd.Parameters.Add("@PdfText", PdfText);
cmd.Parameters.Add("@Pdfid". 1);//Only upload 1 PDF at a time
cmd.Parameters.Add("@Ext", ".pdf");
cmd.ExecuteNonQuery();
}
finally
{
Connection.Close();
}
}