Upload a file into SQL server
Reply
![]() |
|
|
From:
Malli
|
Hi,
here is the code for uploading a file to a database.please check this code Dim fLen As Integer, btData() As Byte Dim objStream As System.IO.Stream Dim insSql As String insSql = "Insert Into SP_File(File_Name,File_Length,File_Data) Values(@fName,@fLen,@fData)" Dim Insertcmd As SqlCommand = New SqlCommand(insSql, cn)
Try fLen = Me.tFile.PostedFile.ContentLength ReDim btData(fLen) objStream = Me.tFile.PostedFile.InputStream objStream.Read(btData, 0, fLen) Insertcmd.Parameters.Add(New SqlParameter("@fName", SqlDbType.NVarChar, 50)).Value = Me.tFile.PostedFile.FileName Insertcmd.Parameters.Add(New SqlParameter("@fLen", SqlDbType.BigInt, 8)).Value = fLen Insertcmd.Parameters.Add(New SqlParameter("@fData", SqlDbType.Image, 16)).Value = btData
Insertcmd.Connection.Open() Insertcmd.ExecuteNonQuery() Insertcmd.Connection.Close() Catch ex As Exception Me.lblError.Text = ex.Message End Try
here i am facing some problem,how can i retrive the data from database.
regards, Malli.
_________________________________________________________________ Get Best prices on your products. http://go.msnserver.com/IN/48714.asp Register for Free on baazee.com.
|
|
View other groups in this category.
![]() |
To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.
Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.
If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.
|
|