Upload (or Download) A File Into (or From) A MS SQL Server DB

Feb 6, 2006

I would like to design a content-management feature on a website, in particular
be able to upload a binary file and to store it into a MS Sql Server DB.
be able to download it afterwards.
The sizes of the files are very limited (less than 100Kb) so I do not need any special feature to handle the upload/download.

Does anyone know how to achieve such feature?

Thanks in advance,
Joannes

View 5 Replies


ADVERTISEMENT

How Do You Upload And Download Images And File From Database?

Mar 7, 2008

Hi,

how do i upload and download images and files from database row?is there anyway i can upload images so that uploaded images ares saved in a listbox and at the same time in the IMAGES folderin the solution explorer as well so that i can later select an image fromlistbox and download it when needed? i m using c#,vwd2005 express,sql express.

thanks.

jack.

View 38 Replies View Related

How Do I Upload To And Download From A Shared SQL Server 2005 Database?

Dec 13, 2006

My hosting gives me ASP.NET 2.0 and a shared SQL Server 2005 package.
I have Visual Studio 2005 on my machine - which installs SQL Server 2005 Express. I have also installed SQL Server 2005 Management Studio Express.
I wish to develop my database locally (mdf file) as I won't always have internet access (and therefore can't always work directly with the remote shared database).
My question is, how do I upload my database info from my local machine to my remote shared database?
Also I shall wish to download my remote database to my local machine in order to work on the database (and then be able to re-upload it) sometimes.
Please can somebody tell me how I can do this?
Will SQL Server 2005 Management Studio Express permit me to do this and if so how?
If I need the full version of SQL Server 2005 Management Studio then I do have SQL Server 2005 and this install with it (but it all looks a bit complicated to install for me).
Many thanks for all help given,
Graham
 

View 1 Replies View Related

Merge Replication, Subscriber Can Only Download But Not Upload??

Apr 28, 2007

Hi,

I need a urgent help! The problem is that every synchronization only transfer data from subscriber to publisher, but not the other direction. The publisher is sql server 2005 standard edition, and the subscriber is 2005 express. Is that any stored-procedure to deal with such a problem?

Thanks for any commnet.

View 14 Replies View Related

Shared Hosting - How Do You Upload/download Your Database?

Apr 27, 2006

Hello,

I am an ASP.NET 2.0/SQL 2005 web developer, and I have run into a huge frustration for some time now that I can't seem to get past. My goal is to develop SQL databases for my costomers on my development machine, and then upload the completed database out to my host. I have not found a host that allows this yet. Some hosts do not allow remote SQL connections altogether, and the best hosts I have been able to find allow remote SQL connections, but do not allow SSIS or DTS packages to run to transfer database objects to the production server.

What does this mean? Well, I have to manually transfer or recreate individual stored procedures and recreate primary, foreign, and other table constraints. I cannot just run a DTS package to transfer the completed objects. So this means duplicating effort, changes for mistakes, and more server downtime during site upgrades. I have called so many host providers, and I haven't found one that can get me past this.

Also, I contacted Microsoft to ask about Licensing (thinking I would just lease a dedicated server), and the only option I can use is SPLA licensing. The catch, I have to lease the OS through SPLA as well, and all the hosts I have contacted put the OS on the server themselves. This means I would be paying for the OS twice.

Ideally, I would just love to find a shared web host package that I could use efficiently with my SQL development. Am I missing something? If anyone has any advice, please help! I would be so appreciative!!! Thanks.

Regards,

Jeremy

View 5 Replies View Related

Upload .xls File To SQL Server

Aug 9, 2005

Here's what I have to do:1. Allow user to locate a .xls file on their machine2. Upload this .xls data into an existing table on a remote SQL ServerI can pull the file from my local machine to another directory on the local machien, but can't figure out have to configure the saveas() to save on the remote db server.It seems you have to save the the db server first on the hard drive, then you can insert the .xls file data into the table.Here's my code so far that works to save on the local machine to another directory on that local machine:Dim getmyFile As HttpPostedFile = myfile.PostedFileIf IsNothing(getmyFile) ThenLabel2.Text = "Please select a file to upload"ElseIf getmyFile.ContentLength = 0 ThenLabel2.Text = "Cannot upload zero length File"ElseDim ServerFileName As String = Path.GetFileName(myfile.PostedFile.FileName)getmyFile.SaveAs("C:TestSaving" & ServerFileName)Label2.Text = "Successful upload to C:TestSaving" & ServerFileNamesCon1.Open()Dim strSQL As StringDim err As IntegerstrSQL = "Insert into ActivityTest Select * FROM OPENROWSET"strSQL &= "('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=D: esting.xls;"strSQL &= "HDR = YES ','SELECT * FROM [Sheet1$]')"Label3.Text = strSQL.ToString()Dim cmd As New SqlCommand(strSQL, sCon1)Trycmd.ExecuteNonQuery()err = "Select @@Error"If err <> 0 ThenLabel4.Text = err.ToString()ElseLabel4.Text = "No Error...line 91!"End IfCatch ex As ExceptionLabel2.Text = "Line 82 Error Updating Table: "Label2.Text &= ex.MessageFinallysCon1.Close()End TryEnd IfThanks for the help in advance!!!!

View 1 Replies View Related

File Upload To SQL Server 6.5 Using Bcp

Jul 15, 1999

Hi,

I am having a problem when I upload a text file to SQL Server 6.5 with bcp utility. The special Chararcter like copy right, registreted etc are not getting uploaded as the same. Its being displayed as a different character when I fire select query from the database.
eg

CIM® is getting uploaded as CIM«

Please help.

Thanks in advance..

View 1 Replies View Related

Upload File To Sql Server

Mar 9, 2004

I got some problem in uploading file into the sql server used ASP.
There is no error occur but the file can't be upload into the database.

This is the connection to the sql server:
function GetConnection()
dim Conn
Conn.Provider = "SQLOLEDB"
Conn.Open "Server=(Local);Database=userinfo", "sa", "sa"
set GetConnection = Conn
end function

function CreateUploadTable(Conn)
dim SQL
SQL = SQL & "CREATE TABLE Upload ("
SQL = SQL & "UploadID int IDENTITY (1, 1) NOT NULL ,"
SQL = SQL & "UploadDT datetime NULL ,"
SQL = SQL & "RemoteIP char (15) NULL ,"
SQL = SQL & "ContentType char (64) NULL ,"
SQL = SQL & "SouceFileName varchar (255) NULL ,"
SQL = SQL & "Title varchar (255) NULL ,"
SQL = SQL & "Description text NULL ,"
SQL = SQL & "Data image NULL "
SQL = SQL & ")"
Conn.Execute SQL
end function

function DBSaveUpload(Fields)
dim Conn, RS
Set Conn = GetConnection

Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open "Upload", Conn, 2, 2
RS.AddNew
RS("UploadDT") = Now()
RS("RemoteIP") = Request.ServerVariables("REMOTE_ADDR")
RS("ContentType") = Fields("DBFile").ContentType
RS("SouceFileName") = Fields("DBFile").FileName
RS("DataSize") = Fields("DBFile").Value.Length

RS("Description") = Fields("Description").Value.String
RS("Title") = Fields("Title").Value.String
if IncludeType=1 then'For ScriptUtilities
RS("Data").AppendChunk Fields("DBFile").Value.ByteArray
Else'For PureASP upload - String is implemented as method.
RS("Data").AppendChunk MultiByteToBinary(Fields("DBFile").Value.ByteArray)
End If

RS.Update
RS.Close
Conn.Close
DBSaveUpload = "Upload has been successfull"
end function

Pls help me!

View 1 Replies View Related

How To Download A File From SQL Server In My Web APP

Nov 24, 2004

Hello people,

Do you know how can do for downloading a file stored in a database?. I'm using a table with a FILE field for storing the file.

I know i have to create a special aspx page for downloading, that receives parameters to locate the proper record in the table and then retrieve the file in memory to start downloading.

I have done this with file located at specific folders but not a database's field.

Another thing... the file may be big.

Dou you have any idea about retrieving from sql and sending the file back to the final user?

I really appreciate your support.

Larry.

View 1 Replies View Related

SQL Server 2000 File Upload

Oct 9, 2007

hi
i am using VS2003 and .net 1.1. i need to upload a cert file into sql server 2000. code is as follows, i am not sure if this code is working or not, its not giving any error nor throwing any exception. in this function i am only converting ther .cer file to byte array. and in other function i am passing this byte to a stored procedure. in stored procedure i have declare a parameter as "@cert binary". i cant see the binary data in sql server 2000, its only showin <binary> in that column. i need to download this file now, how can i do that. Dim selectedCert As HttpPostedFile
Dim certLength As Integer
Dim isValid As Boolean = False
'Dim imageType As String
'Dim fileUpload As System.Web.UI.HtmlControls.HtmlInputFile = .FindControl("fileUpload")
selectedCert = fileUpload.PostedFile
certLength = selectedCert.ContentLength
'imageType = selectedCert.ContentType
Session.Add("isDefaultLogo", 0) ' To check if default logo is used
If fileUpload.PostedFile.ContentLength = 0 Then
' DO NOTHING
ElseReDim binaryCert(certLength - 1)
'check if there a certificate file or not
If (selectedCert.ContentLength = 0) Then
' DO SOMETHING
Else
selectedCert.InputStream.Position = 0
selectedCert.InputStream.Read(binaryCert, 0, certLength - 1)
Response.Write(selectedCert.ContentType.ToString)
If (selectedCert.ContentType.ToLower <> "application/x-x509-ca-cert") Then
lblMsg.Visible = True
lblMsg.Text = "Only Certificate (*.cer) files are allowed."
isValid = True
Return False
End If
End If
End If
If isValid Then
TryDim strm As IO.FileStream = System.IO.File.Open(System.IO.Path.GetFullPath(fileUpload.PostedFile.FileName), IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.ReadWrite)ReDim binaryCert(strm.Length - 1)
strm.Read(binaryCert, 0, strm.Length)
strm.Close()Catch ex As Exception
Return False
End Try
End If
 
thnx in advance
cheers

View 3 Replies View Related

I Don't Know How Can I Upload My Sqlserver File To The Server

Jul 26, 2004

I don't know How can i upload my sqlserver file to the server
could you help me?
could you write an example code in query analyser for
uploading sql server file to database

View 1 Replies View Related

How To Upload A File To A Server URL Using Web Service Task?

Jun 28, 2006

Hi,

I have been trying to setup a web service task to use my http connection manager that connects to a server url. What I want to do is to upload a file to a web server... can this be done using web service task? and what is the WSDL? and what happens when my target server usis SSL? so instead of http, it should use https? I need help with this one... can't quite imagine how to get things rolling..

Thanks in advance!
Kervy

View 12 Replies View Related

Download File That Is Stored In Sql Server Database

Feb 20, 2007

Hi, I have tried to implement file download option. I can download file which is stored in any folder. Code is...        string filepath = Request.Params["file"].ToString();        string filename = Path.GetFileName(filepath);        Response.Clear();        Response.ContentType = "image/gif";        Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);        Response.Flush();        Response.WriteFile(filepath);This code is working fine. But now I am facing a problem. Files (not the path) are stored in database table. User can download file from the database. How can I do this? The file may be a .txt, .doc, .xls, .jpg or .gif.

View 13 Replies View Related

SQL Server 2005 Trial - Which File To Download?

Jun 21, 2006

Hi all,

I am extracting SQL server 2005 trial edition to my flash memory hard drive.

Hence suppose I should download one of the following three files:

"Self-extracting executables:

X86 Executable
X64 Executable
IA64 Executable "

But which one should I choose? based on what criteria ?

(This point seems clear to everyone but myself, even after I went through all the docs on the download site)

Thanks,

Jack (an absolute beginner)

View 6 Replies View Related

Upload File - Pass Variable - Fire DTS Sql Server 2000

Jul 31, 2006

Hi All,
I am looking to do the following:
1) Upload a text file via a website to a server with sql server 2000.
2) Fire a DTS package on that file so it appends the contents to a table in the database.
3) Choose a variable via a dropdown list on the website
4) Run a different DTS Package that uses an update sql statement that uses that Variable.
Any help or suggestions would be greatly appreciated.
Thanls,
Doug
 

View 6 Replies View Related

SQL CONNECTION - INSERT - RETRIEVE ID - Rename File - UPLOAD FILE

Sep 15, 2007

Hi there,
I have inherited a databse and am building a new website to go wiht it.
There is a file upload page which will upload images to a directory.  I need to insert into the database retrieve the id just added then upload the image renaming it in the format locID(QueryString)_ImageID(retrieved from database).jpg
The page has a file upload control and a button.
I am trying to write my code behind so that when the button is clicked it inserts location id into the images table retrieves Image id. Renames the file and uploads it to the images folder.
II think i need to call the routine from another routine for the button click but the signatures are different, where am i going wrong? or for that matter have i been pissing into the wind for the last 4 hours?
CODE BEHIND

Imports System.Data
Imports System.Data.SqlClientPartial Class admin_Add_Images
Inherits System.Web.UI.PageProtected Sub UploadImage(ByVal Sender As Object, ByVal e As SqlDataSourceStatusEventArgs)
Dim LocationId As String = Request.QueryString(ID)

' create a new SqlConnectionDim NewConn As New SqlConnection
NewConn = New SqlConnection("server=desktopsqlexpress;uid=xxxxxx;pwd=xxxxxxx;database=MYLOCDEV") 'OleDbConnection i
' open the connection
NewConn.Open()Dim MyInsert = New SqlCommand("INSERT into image([LocationID]) VALUES (@LocationID); SET @NewId = Scope_Identity()")
NewConn.Close()
If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then
'RENAME THE FILEDim newid As Integer = e.Command.Parameters("@NewId").Value
Dim fn As String = (LocationId & "_" & newid & ".jpg")Dim SaveLocation As String = Server.MapPath("oicImages") & "" & fn
Try
File1.PostedFile.SaveAs(SaveLocation)Response.Write("The file has been uploaded.")
Catch Exc As ExceptionResponse.Write("Error: " & Exc.Message)
End Try
ElseResponse.Write("Please select a file to upload.")

End If
End SubProtected Sub Submit1_Click(ByVal Sender As Object, ByVal e As System.EventArgs) Handles Submit1.Click

UploadImage()End Sub
End Class

View 2 Replies View Related

Adding File Information To SQL Database On File Upload

Apr 18, 2004

Hi there :)

I'm in the final stage of my asp.net project and one of the last things I need to do is add the following file information to my SQL server 2000 database when a file is uploaded:

First of all I have a resource table to which I need to add:
- filename
- file_path
- file_size
(the resource_id has a auto increment value)

so that should hopefully be straight forward when the file is uploaded. The next step is to reference the new resource_id in my module_resource table. My module resource table consists of:
- resource_id (foreign key)
- module_id (foreign key)

So, adding the module_id is easy enough as I can just get the value using Request.QueryString["module_id"]. The bit that I am unsure about is how to insert the new resource_id from the resource table into the module_resource table on file upload. How is this done? Using one table would solve the issue but I want one resource to be available to all modules - many to many relationship.

Any ideas?

Many thanks :)

View 1 Replies View Related

Integration Services :: How To Upload Excel File Using SSIS With Out Excel Installed On Server

Jul 25, 2015

Trying to upload excel in server where excel is not installed. BIDs was there in the server, when i am trying to craete Excel source I am not able.what the workround for this.. How to upload excel without excel installed on the server.

View 4 Replies View Related

File Upload Help

Dec 11, 2007

Hi, I am trying to upload a file to database.
I have used the following code, every loads good to the database apart from the image, does it go anywhere?
I have created a column in the table called 'FileUploadAdvert' and made it an image?
Any ideas where I'm going wrong?
ThanksGordon 
Protected Sub btnAdvertSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdvertSubmit.ClickDim dashDataSource As New SqlDataSource()dashDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("DashConnectionString1").ToString()
dashDataSource.InsertCommandType = SqlDataSourceCommandType.Text
dashDataSource.InsertCommand = "INSERT INTO tblAdvert (AdvertOwner, AdvertName, TopLeftH, TopLeftV, Height, Width, ToolTip, WebLink, AcceptTerms, DateTimeStamp, IPAddress) VALUES (@AdvertOwner, @AdvertName, @TopLeftH, @TopLeftV, @Height, @Width, @ToolTip, @WebLink, @AcceptTerms, @DateTimeStamp, @IPAddress)"dashDataSource.InsertParameters.Add("AdvertOwner", txtName.Text)
dashDataSource.InsertParameters.Add("AdvertName", txtCompName.Text)dashDataSource.InsertParameters.Add("TopLeftH", DropDownAccross.Text)
dashDataSource.InsertParameters.Add("TopLeftV", DropDownDown.Text)dashDataSource.InsertParameters.Add("Height", DropDownHeight.Text)
dashDataSource.InsertParameters.Add("Width", DropDownWidth.Text)dashDataSource.InsertParameters.Add("ToolTip", txtOver.Text)
dashDataSource.InsertParameters.Add("Weblink", txtURL.Text)dashDataSource.InsertParameters.Add("AcceptTerms", CheckBoxAgree.Checked)
dashDataSource.InsertParameters.Add("IPAddress", Request.UserHostAddress.ToString)dashDataSource.InsertParameters.Add("DateTimeStamp", DateTime.Now)
If Not FileUploadAdvert.PostedFile Is Nothing ThenDim filepath As String = FileUploadAdvert.PostedFile.FileName
Dim pat As String = "\(?:.+)\(.+).(.+)"Dim r As Regex = New Regex(pat)
'runDim m As Match = r.Match(filepath)
Dim file_ext As String = m.Groups(2).Captures(0).ToString()Dim filename As String = m.Groups(1).Captures(0).ToString()
Dim file As String = filename & "." & file_ext
'save the file to the server FileUploadAdvert.PostedFile.SaveAs(Server.MapPath(".") & file)
lblStatus.Text = "File Saved to: " & Server.MapPath(".") & fileEnd If
 Dim rowsAffected As Integer = 0
Try
rowsAffected = dashDataSource.Insert()Catch ex As Exception
Server.Transfer("Register_Fail.aspx")
Finally
dashDataSource = Nothing
End Try
If rowsAffected <> 1 ThenServer.Transfer("Register_Fail.aspx")
ElseServer.Transfer("Register_Complete.aspx")
End If
End Sub

View 4 Replies View Related

File Upload To SQL In 2.0 VB

May 2, 2006

Can anyone give me an example of how to Upload a file to SQL in asp.net 2.0 using VB?
 
Thanks
Randy

View 2 Replies View Related

Upload File

May 5, 2008

Hello

I am using Microsoft SQL Server Management Studio Express and want to insert a row into a table. The table (Pictures) has the following columns: ID (int), Filename (varchar), Data (varbinary).

INSERT INTO Pictures(ID, Filename, Data) VALUES
(12, 'photo.jpg', C:photo.jpg);


The statement above does not work. How do you do it?

Thank you

View 1 Replies View Related

Store A File Upload Into DB

Sep 10, 2007

Can someone please direct me to a discussion on which version of SQL Server allows a file to be stored in a db field and how this is accomplished as well as how the file is then retrieved with asp.net VB from the DBthanksMilton

View 16 Replies View Related

Upload File Only Works For Dbo

Nov 6, 2007

Hi there,
My problem is that the upload works in testing for our asp.net site only for dbo. Being mindful of security, I would prefer not use this account to execute all sp_/sql. One solution could be using impersonation only in the content management system where the uploading is done, this is code in web.config:
  <location path="Manage.aspx">    <system.web>    <identity impersonate="true" userName="dbo" password="****" />      <authorization>        <deny users="?" />      </authorization>    </system.web>  </location>
To do this I would have to change the dbo password as set up by previous employee, not a real dba so not sure of the implications (enough permissions to be dangerous though;). Is the above impersonation ok, or should I redo logins security in sql? Thanks.

View 1 Replies View Related

Cannot Upload File To Database

Mar 16, 2006

  Can anyone correct my code?I will like to add a url to my database and upload my image to web server.txtAddTitle will become my title nametxtFileName allow user to type in image name that will upload to webserver and at the meantime will insert into database as url referencesvalue for @chapterid will get from drop down list(ddlLesson) and the index value will store in database.
now i am able to upload my images with the file name that i have given to web server, but I am unable to insert data to my database.
 Sub DoUpload(ByVal Sender As Object, ByVal e As System.EventArgs)        Dim sPath As String        Dim sFile As String        Dim sFullPath As String        Dim sSplit() As String        Dim sPathFriendly As String
              'Upload to same path as script. Internet Anonymous User must have write permissions        sPath = Server.MapPath("../Tutorial")        'sPath = Server.MapPath(".")        If Right(sPath, 1) <> "" Then            sPathFriendly = sPath 'Friendly path name for display            sPath = sPath & ""        Else            sPathFriendly = Left(sPath, Len(sPath) - 1)        End If
        'Save as same file name being posted        'The code below resolves the file name        '(removes path info)        sFile = txtFileName.Text        'sFile = txtUpload.PostedFile.FileName        sSplit = Split(sFile, "")        sFile = sSplit(UBound(sSplit))
        sFullPath = sPath & sFile        Try            txtUpload.PostedFile.SaveAs(sFullPath)            lblResults.Text = "<br>Upload of File " & sFile & " to " & sPathFriendly & " succeeded"
        Catch Ex As Exception
            lblResults.Text = "<br>Upload of File " & sFile & " to " & sPathFriendly & " failed for the following reason: " & Ex.Message        Finally            lblResults.Font.Bold = True            lblResults.Visible = True        End Try
        Dim mycommand As SqlCommand        Dim myConnection As SqlConnection        Message.InnerHtml = ""        'to all the valur to database        If IsValid Then
            myConnection = New SqlConnection("Server=localhost;UID=sa;pwd=;database=u")            mycommand = New SqlCommand("INSERT INTO t_linkTitle(link_chapterid,link_name,link_url) VALUES (@chapterid,@titleName,@titleUrl)", myConnection)
            mycommand.Parameters.Add("@chapterid", SqlDbType.VarChar, 50).Value = ddlLesson.SelectedItem.Value            mycommand.Parameters.Add("@titleName", SqlDbType.VarChar, 50).Value = txtAddTitle.Text            mycommand.Parameters.Add("@titleUrl", SqlDbType.VarChar, 100).Value = txtFileName.Text
            mycommand.Connection.Open()            msgErrorTitle.Style("color") = "OrangeRed"            Try                mycommand.ExecuteNonQuery()                msgErrorTitle.InnerHtml = "New title <b>" + txtAddTitle.Text + "</b> Added to " + "<b>" + ddlLesson.SelectedItem.Text + "</b><br>" + mycommand.ToString()            Catch Exp As SqlException
                If Exp.Number = 2627 Then                    msgErrorTitle.InnerHtml = "ERROR: Title already exists. Please use another title"                Else                    msgErrorTitle.InnerHtml = "ERROR: Could not add record, please ensure the fields are correctly filled out"                End If
            End Try
            mycommand.Connection.Close()        End If
        LoadTitle()
    End Sub

View 2 Replies View Related

Upload File To A DB In Binary

Apr 20, 2006

Hi have done the following but get the errors at the end, any ideas
 Created a stored procedureALTER PROCEDURE ulfile@upload varchar(200)ASINSERT INTO results(@upload)VALUES (@Upload)RETURN after sitting for two hours I realised I had a comma after (200) then the following in the .cs file using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class Default3 : System.Web.UI.Page{//PostedFile Property of Type HTTPPostedFileint intDocLen = txtFileContents.PostedFile.ContentLength;byte[] Docbuffer = new byte[intDoclen];protected void Page_Load(object sender, EventArgs e){ Stream objStream;//InputStream://Gets a Stream object which points to an uploaded Document; //to prepare for reading the contents of the file.objStream = txtFileContents.PostedFile.InputStream;objStream.Read(Docbuffer, 0, intDocLen);//results is the connection objectcmdUploadDoc = new SqlCommand("ulfile", results);cmdUploadDoc.CommandType = CommandType.StoredProcedure;//Add the Params which in the Stored Proc cmdUploadDoc.Parameters.Add("@upload ", SqlDbType.VarChar, 200);//Set Params ValuescmdUploadDoc.Parameters[0].Value = txtTitle.Text;//Set the "@Doc" Param to be Docbuffer byet ArraycmdUploadDoc.Parameters[1].Value = Docbuffer;cmdUploadDoc.Parameters[2].Value = strDocType; }private void btnSubmit_Click(object sender, System.EventArgs e){string strDocExt;//strDocType to store Document type which will be Stored in the Databasestring strDocType;//Will be used to determine Document lengthint intDocLen;//Stream object used for reading the contents of the Uploading DocumnetStream objStream;SqlConnection results;SqlCommand cmdUploadDoc;if(IsValid){if(txtFileContents.PostedFile != null){//Determine File TypestrDocExt = CString.Right(txtFileContents.PostedFile.FileName,4).ToLower();switch(strDocExt){case ".doc":strDocType = "doc";break;case ".ppt":strDocType = "ppt";break;case ".htm":strDocType = "htm";break;case ".html":strDocType = "htm";break;case ".jpg":strDocType = "jpg";break;case ".gif":strDocType = "gif";break;case ".im":strDocType = "im";break;default:strDocType = "txt";break;}//Grab the Content of the Uploaded DocumentintDocLen = txtFileContents.PostedFile.ContentLength;//buffer to hold Document Contentsbyte[] Docbuffer = new byte[intDocLen];//InputStream://Gets a Stream object which points to an uploaded Document; //to prepare for reading the contents of the file.objStream = txtFileContents.PostedFile.InputStream;//Store the Content of the Documnet in a buffer//This buffer will be stored in the DatabaseobjStream.Read(Docbuffer ,0,intDocLen);//Add Uploaded Documnet to Database as Binary//You have to change the connection stringBooksConn = new SqlConnection("Server=66.179.84.110;UID=******;PWD=******;Database=******");//Setting the SqlCommandcmdUploadDoc = new SqlCommand("ulfile",results);cmdUploadDoc.CommandType = CommandType.StoredProcedure;cmdUploadDoc.Parameters.Add("@upload ",SqlDbType.VarChar,200);cmdUploadDoc.Parameters[0].Value = txtTitle.Text;cmdUploadDoc.Parameters[1].Value = Docbuffer ;cmdUploadDoc.Parameters[2].Value = strDocType;Results.Open();cmdUploadDoc.ExecuteNonQuery();Results.Close();}//End of if(txtFileContents.PostedFile != null)}//End Of if(IsValid)}//End of Method btnSubmit_Click}  And the form code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"><title>Untitled Page</title></head><body><form id="frmUpload" method="post" enctype="multipart/form-data" runat="server"><span>Title</span><asp:textbox id="txtTitle" runat="server" EnableViewState="False"></asp:textbox><asp:requiredfieldvalidator id="valrTitle" runat="server" ErrorMessage="* Required" ControlToValidate="txtTitle">* Required</asp:requiredfieldvalidator><span>Document to Upload</span><input id="txtFileContents" type="file" runat="server" name="txtFileContents"></></><asp:button id="btnSubmit" Text="Submit" Runat="server" OnClick="btnSubmit_Click"></asp:button>   </form></body></html>  however when I try and view in browser I get the following Line 21:
Line 22:
Line 23: Stream objStream;
Line 24: //InputStream:
Line 25: //Gets a Stream object which points to an uploaded Document;  I have trawlled the net, MSDN and anywhere else I can find to see what it is and nothing. eventually changed  Stream.objstream to System.IO.Stream objStream; And now getting the following error Line 29:
Line 30: //results is the connection object
Line 31: cmdUploadDoc = new SqlCommand("ulfile",results);
Line 32: cmdUploadDoc.CommandType = CommandType.StoredProcedure;
Line 33: //Add the Params which in the Stored Proc  Can anyone help?

View 2 Replies View Related

What Is The Best Way To Upload Huge File Into SQL 2K

Mar 13, 2002

I have a 2 GB text file(semicolon delimited), which I need to
pump into SQL 2K. What is the best way to achieve this in shortest time?

I tried with DTS BCP, it tooks 1 minute 14 secs to transfer 13457 records. This is only 1/2000 of the record i need to transfer. Please help.

Thanks.

regards,
Terry

View 2 Replies View Related

HTTP File Upload

Aug 11, 2006

I'm looking for a way with Integration Services in SQL'05 to upload a file. How could I do this? Is there any examples out there?

This partuclar HTTP Server has WEBDAV configured so if I could just point to the URL location and new FILE that would be excellent.

Thanks

View 2 Replies View Related

XLSX File Upload

Oct 23, 2007

Hi,



I uploaded an xlsx file to my reporting services. When i click on the xlsx file link in the reporting services frontend, a internet explorer window is opened with the xlsx file information (reporting services) and the xlsx file is opened by the excel application.



Is there any way to prevent the Internet explorer window to be opened?


Regards.

View 4 Replies View Related

Upload And Save A PDF File Into MS SQL Databse

Apr 13, 2007

Hi guys,
 I want to update a PDF file and store it in the MSSQL database. (I know it is better if I save the file on server and just store the link to it, but I have to store the file on the database "Project Requirements")
I would probably use FileUpload control to upload the file. but would I upload it to server temporarly and then save it or would I just upload it to DB.
I appreciate your help and suggestions and any tips & tricks or issue that I have to consider.
Regards,Mehdi

View 2 Replies View Related

Upload File To Database Using Sqldatasource

Sep 12, 2007

Hi,I am trying to upload a file to a database. I have all the code set up but I get this error message: Operand type clash: nvarchar is incompatible with image  The following is the code that I have: 1 If FileUpload1.PostedFile Is Nothing OrElse String.IsNullOrEmpty(FileUpload1.PostedFile.FileName) OrElse FileUpload1.PostedFile.InputStream Is Nothing Then
2 lblInfo.Text = "No file selected"
3 Exit Sub
4 End If
5
6 Dim extension As String = Path.GetExtension(FileUpload1.PostedFile.FileName).ToLower()
7 Dim MIMEType As String = Nothing
8
9 Select Case extension
10 Case ".gif"
11 MIMEType = "image/gif"
12 Case ".jpg", ".jpeg", ".jpe"
13 MIMEType = "image/jpeg"
14 Case ".pdf"
15 MIMEType = "application/pdf"
16 Case ".doc"
17 MIMEType = "application/msword"
18 Case ".swf"
19 MIMEType = "application/x-shockwave-flash"
20 Case ".txt", ".html"
21 MIMEType = "text/plain"
22 Case Else
23 lblInfo.Text = "Invalid file upload"
24 Exit Sub
25 End Select
26
27 Dim imageByte(FileUpload1.PostedFile.InputStream.Length) As Byte
28 FileUpload1.PostedFile.InputStream.Read(imageByte, 0, imageByte.Length)
29
30 sqlInsert = "INSERT INTO Pages (MIMEType, ImageData) VALUES (@MIMEType, @ImageData)"
31 SqlDataSource1.InsertCommand = sqlInsert
32 SqlDataSource1.InsertParameters.Add("MIMEType", MIMEType.ToString.Trim)
33 SqlDataSource1.InsertParameters.Add("ImageData", imageByte.ToString)
34 SqlDataSource1.InsertCommand = sqlInsert
35 SqlDataSource1.Insert()
36 SqlDataSource1.InsertParameters.Clear()I problem happen at line 33. I have tried using sqldatasource1.InsertParameters.add("ImageData", imageByte), it doesn't like it.Please help  

View 2 Replies View Related

Upload Files And Downloading A Pdf File

Mar 5, 2008

what data type am i going to put to my uploadedFiles column in my database... uploaded files are in document format or .txt
 also.. how can i make those files converted into pdf files.. also enable users to download it..
tnx!!!
forums.asp.net = "great help"

View 7 Replies View Related

Upload / Display Image File

Dec 3, 2007

Does anyone know how can I insert image file into SQL Server table…?
How can I display image field using SQL Server command like Photo on Northwind database…?

Thanks
Sbahri

View 1 Replies View Related

Upload Text File To A Table

Nov 1, 2007

I do have a comma separated text file.
"firstname","lastname","ssn","dob"
"firstname1","lastname1","ssn1","dob1"

The text file can have 50000 records. What is the best way to upload the file into a table. The table structure looks like:

Table1:
Fname varchar(50)
lname varchar(50)
ssn varchar(50)
dob varchar(50)

Any thoughts???

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved