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


ADVERTISEMENT

Upload A File Onto The Database - Image Datatype

Sep 23, 2005

I am using the image datatype to upload files onto SQL SErver 2000. My
problem is that it seems as though the database is only accepting files
of size 65Kb or less.
What is the best way of resolving this problem?

View 2 Replies View Related

How To Display File/image From Mssql Server?

Feb 4, 2005

i've some records in the mssql server which are actually files or images. They're stored in either binary fields or image fields.

thus how do i display these files out? or let people download them???how do i write such aspx? thanks

View 2 Replies View Related

How Can I Uplaod Image File To SQL Server And Display Uploaded Files

Jan 28, 2008

This is my first time to create web site by using Visual web developer express 2005. I want to create company's activity member profile web page by use sql database. But I don't know how to create SQL DB and Table and I don't know code for connect to sql server, code for upload image files, data file, and code for displays images. So please tell me how to do it step by step. (I use VS web developer express 2005 with vb.net) Thank you 

View 3 Replies View Related

Retrieve And Display Image Inside An Html File (stored In Database) In Binary Format

May 15, 2007

Hi All,
I am not sure whether this is the right place to post this question. But I am unable to figure out what is the best solution to retrieve and display an image in a html file(stored in varbinary(max) column). I have a list of images in the file and I am supposed to display them. Can anybody please let me know what is the best way to do this?
Thanks a lot!!

View 1 Replies View Related

How To Save Image In Sql Server And Display That Image In Datagrid??

Jun 27, 2007

Hay Friend's
Can u plese send me the way how to save image in sql server and display that images in datagrid or other control also like Image control or Image control Button?? Plese send the coding in C#.
 Thank's
Amit

View 5 Replies View Related

HOW To Retrieve An Image From Sql Server And Display It In ASP.net Using Imagemap Or Image ?

Jul 6, 2006

Ok, the problem is that , i have a field called "Attach" in sql of type image, when selecting it , the field is getting data of type BYTE(). which am being unable to display them on an Image on the panel.

using the following vb.net code:

'Dim sel2 As String

'Dim myCom As SqlCommand

'Dim conn As New SqlConnection

'Dim drr As SqlDataReader

'Dim image As System.Drawing.Image

'sel2 = "select * from attach where att_desc = '" & DropDownList1.SelectedItem().Text & "' and doc_code = " & w_doc_code & " and subcode = " & w_doc_subcode & " and doc_num= " & w_doc_num & " "

'conn.ConnectionString = ("server=developer01;uid=sa;password=aims;database=DVPSOC;timeout=45")

'myCom = New SqlCommand(sel2, conn)

'conn.Open()

'drr = myCom.ExecuteReader()

'If drr.Read Then

' Me.ImageMap1.ImageUrl = drr.Item("attach")

'End If

'conn.Close()

Am getting an exeption on the following line Me.ImageMap1.ImageUrl = drr.Item("attach")

saying: Conversion from type 'Byte()' to type 'String' is not valid.

knowing that i tried converting using ToString but it's not getting any output then.

thanks for your help.

View 4 Replies View Related

Upload An Image ....?!

Dec 24, 2006

I used upload image feature and below is the code that I used. The image is stored in a folder. I want to save the image in sql database. I create the database which is “database�, and I create a table which is “user�. User table has auto “id� field and “image� field. I want to save the image in the image field. I need your help to do the other codes.
 
I am using asp.net with VB
 
This is what I did so far:
============================
Partial Class upload
    Inherits System.Web.UI.Page
    Dim strFileName As String
 
    Protected Sub btnupload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnupload.Click
        UploadImage()
    End Sub
    Sub UploadImage()
 
        If Not (fileupload1.PostedFile Is Nothing) Then 'Check to make sure we actually have a file to upload
 
            Dim strLongFilePath As String = fileupload1.PostedFile.FileName
            Dim intFileNameLength As Integer = InStr(1, StrReverse(strLongFilePath), "")
            strFileName = Mid(strLongFilePath, (Len(strLongFilePath) - intFileNameLength) + 2)
 
            Select Case fileupload1.PostedFile.ContentType
                Case "image/pjpeg", "image/jpeg" 'Make sure we are getting a valid JPG image
                    FileUpload1.PostedFile.SaveAs(Server.MapPath(" estimages") & strFileName)
                    lbstatus.Text = strFileName & " was uploaded successfully to: " & Server.MapPath(" estimages") & strFileName
 
                Case Else
                    'Not a valid jpeg image
                    lbstatus.Text = "Not a valid jpeg image"
            End Select
 
            InsertToDatabase()
        End If
 
 
    End Sub

End class

View 1 Replies View Related

How Image Display From SqlServer To Image Control

Feb 13, 2007

I have learned lots of informative thing from your forums. I have little problem regarding “Display image from SQL Server on ASP.NET� I have done it and image display on my page from SQL Server. I have cleared you here I have adopt two different methods which are following for displaying picture.

1.Response.BinaryWrite(rd("picture"))
2.image.Save(Response.OutputStream, ImageFormat.Jpeg)

but in both above methods I have faced little problem when image display on my page all other information can not display and I also want to display picture on my specific location on the page. My second question is can use any web control like “Image1� to display image from SQL Server where my pictures are stored.

Hope you will help me.

Thanks and regards


Aftab Abbasi

View 4 Replies View Related

Please Help Me... How Can I Upload Image Into My Sql Database

Nov 12, 2007

 Please help me... How can i upload image into my sql database in a basic way... thanks....

View 6 Replies View Related

Upload Image To SQL Database

Apr 3, 2006

I am creating a update, delete, edit form for my web database.  The form works in everyway except that when I try to upload the image to the database it does not go into the database.  (I know the pros and cons of storing images in a database.  In this instance it is what makes the most since. )
I have to admit I have never uploaded anything to my server or database before (other than plain text). I have read through several articles and have a high level of understanding.
I found an example on a website that used the OnInserting/OnUpdating command. But it is not working.  I tried to find another similar example so that I could better understand it and try to fix what must be wrong.  I can't find a similar example.
I am posting the code I have below. Any help would be most appreciated.
 
C# Code Behind
using System;
using System.Data;
using System.Data.SqlClient;
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 html_Test_Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DetailsView1_ItemUpdated(Object sender, System.Web.UI.WebControls.DetailsViewUpdatedEventArgs e)
{
Response.Redirect("GridViewMasterDetailsInsertPage_cs.aspx");
}
protected void DetailsView1_ModeChanging(Object sender, System.Web.UI.WebControls.DetailsViewModeEventArgs e)
{
if (e.CancelingEdit == true)
{
Response.Redirect("GridViewMasterDetailsInsertPage_cs.aspx");
}

}
protected void SqlDataSource3_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
FileUpload stateTextBox = (FileUpload)DetailsView1.Rows[2].Cells[0].Controls[1];
System.IO.Stream inputStream = stateTextBox.PostedFile.InputStream;
int imageLength = stateTextBox.PostedFile.ContentLength;
byte[] imageBinary = new byte[imageLength];
int inputRead = inputStream.Read(imageBinary, 0, imageLength);
byte[] imageData = imageBinary;
System.Data.SqlClient.SqlParameter uploadData = new System.Data.SqlClient.SqlParameter("@photo", System.Data.SqlDbType.Image);
uploadData.Value = imageData;
e.Command.Parameters.Add(uploadData);
}
protected void New_Click(object sender, EventArgs e)
{
DetailsView1.ChangeMode(DetailsViewMode.Insert);
}
 
 
}
*************************************ASPX page
<%@ Page Language="C#" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="true" CodeFile="DetailsViewEdit_cs.aspx.cs" Inherits="html_Test_Default3" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form id="form1" runat="server" method="post" enctype="multipart/form-data">
<asp:DetailsView DefaultMode="Edit" AutoGenerateRows="False" DataKeyNames="recID"
DataSourceID="SqlDataSource3" HeaderText="Edit Articles" ID="DetailsView1" runat="server"
Width="275px" OnItemUpdated="DetailsView1_ItemUpdated" OnModeChanging="DetailsView1_ModeChanging">
<Fields>
<asp:BoundField DataField="recID" HeaderText="Record Number" SortExpression="recID" ReadOnly="True" />
<asp:TemplateField SortExpression="LiveAccess" HeaderText="LiveAccess" >
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" AppendDataBoundItems="true" runat="server" DataSourceID="SqlDataSource3" DataTextField="LiveAccess" DataValueField="LiveAccess" SelectedValue='<%# Bind("LiveAccess") %>'>
<asp:ListItem Text="Yes" Value="Yes" />
<asp:ListItem Text="No" Value="No" />
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField SortExpression="DevelopmentAccess" HeaderText="DevelopmentAccess" >
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" AppendDataBoundItems="true" runat="server" DataSourceID="SqlDataSource3" DataTextField="DevelopmentAccess" DataValueField="DevelopmentAccess" SelectedValue='<%# Bind("DevelopmentAccess") %>'>
<asp:ListItem Text="Yes" Value="Yes" />
<asp:ListItem Text="No" Value="No" />
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField SortExpression="MediaAccess" HeaderText="MediaAccess" >
<EditItemTemplate>
<asp:DropDownList ID="DropDownList3" AppendDataBoundItems="true" runat="server" DataSourceID="SqlDataSource3" DataTextField="MediaAccess" DataValueField="MediaAccess" SelectedValue='<%# Bind("MediaAccess") %>'>
<asp:ListItem Text="Yes" Value="Yes" />
<asp:ListItem Text="No" Value="No" />
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField SortExpression="DoctorAccess" HeaderText="DoctorAccess" >
<EditItemTemplate>
<asp:DropDownList ID="DropDownList4" AppendDataBoundItems="true" runat="server" DataSourceID="SqlDataSource3" DataTextField="DoctorAccess" DataValueField="DoctorAccess" SelectedValue='<%# Bind("DoctorAccess") %>'>
<asp:ListItem Text="Yes" Value="Yes" />
<asp:ListItem Text="No" Value="No" />
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField SortExpression="DealerAccess" HeaderText="DealerAccess" >
<EditItemTemplate>
<asp:DropDownList ID="DropDownList5" AppendDataBoundItems="true" runat="server" DataSourceID="SqlDataSource3" DataTextField="DealerAccess" DataValueField="DealerAccess" SelectedValue='<%# Bind("DealerAccess") %>'>
<asp:ListItem Text="Yes" Value="Yes" />
<asp:ListItem Text="No" Value="No" />
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ContentType" HeaderText="ContentType" SortExpression="ContentType" />
<asp:BoundField DataField="ProductType" HeaderText="ProductType" SortExpression="ProductType" />

<asp:BoundField DataField="ReviewDate" HeaderText="ReviewDate" SortExpression="ReviewDate" />
<asp:BoundField DataField="ReleaseDate" HeaderText="ReleaseDate" SortExpression="ReleaseDate" />
<asp:BoundField DataField="ObsoleteDate" HeaderText="ObsoleteDate" SortExpression="ObsoleteDate" />
<asp:TemplateField HeaderText="Title">
<EditItemTemplate>
<asp:TextBox id="EditTitle" Text='<%# Bind("Title") %>' Runat="Server"
TextMode="SingleLine" Rows="1" Width="400px" Font-Size="9pt"/>
</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Sub Title">
<EditItemTemplate>
<asp:TextBox id="EditSubtitle" Text='<%# Bind("Subtitle") %>' Runat="Server"
TextMode="SingleLine" Rows="1" Width="400px" Font-Size="9pt"/>
</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Copy">
<EditItemTemplate>
<asp:TextBox id="EditCopy" Text='<%# Bind("Copy") %>' Runat="Server"
TextMode="MultiLine" Rows="5" Width="400px" Font-Size="9pt"/>
</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Keywords">
<EditItemTemplate>
<asp:TextBox id="Keywords" Text='<%# Bind("Keywords") %>' Runat="Server"
TextMode="MultiLine" Rows="5" Width="400px" Font-Size="9pt"/>
</EditItemTemplate>
</asp:TemplateField>

<asp:ImageField DataImageUrlField="Picture"></asp:ImageField>
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:FileUpload ID="FileUpload1" FileName='<%# Bind("Picture") %>' runat="server" />
<asp:RequiredFieldValidator ID="FileUploadValidator" ControlToValidate="FileUpload1" runat="Server">*</asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Notes">
<EditItemTemplate>
<asp:TextBox id="EditNotes" Text='<%# Bind("Notes") %>' Runat="Server"
TextMode="MultiLine" Rows="5" Width="400px" Font-Size="9pt"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="WriterName" HeaderText="WriterName" SortExpression="WriterName" />
<asp:BoundField DataField="WriterEmailAddress" HeaderText="WriterEmailAddress" SortExpression="WriterEmailAddress" />
<asp:BoundField DataField="Language" HeaderText="Language" SortExpression="Language" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:myConnection %>"
SelectCommand="SELECT [recID], [Date], [LiveAccess], [DevelopmentAccess], [MediaAccess], [DoctorAccess], [DealerAccess], [ContentType], [ProductType], [Title], [Subtitle], [ReviewDate], [ReleaseDate], [ObsoleteDate], [Keywords], [Picture], [Copy], [Notes], [WriterName], [WriterEmailAddress], [Language] FROM [Articles] WHERE ([recID] = @recID)"
UpdateCommand="UPDATE [Articles] SET [LiveAccess]=@LiveAccess, [DevelopmentAccess]=@DevelopmentAccess, [MediaAccess]=@MediaAccess, [DoctorAccess]=@DoctorAccess, [DealerAccess]=@DealerAccess, [ContentType]=@ContentType, [ProductType]=@ProductType, [Title]=@Title, [Subtitle]=@Subtitle, [ReviewDate]=@ReviewDate, [ReleaseDate]=@ReleaseDate, [ObsoleteDate]=@ObsoleteDate, [Keywords]=@Keywords, [Picture]=@Picture, [Copy]=@Copy, [Notes]=@Notes, [WriterName]=@WriterName, [WriterEmailAddress]=@WriterEmailAddress, [Language]=@Language WHERE [recID] = @recID"
OnUpdating="SqlDataSource3_Inserting">
<SelectParameters>
<asp:QueryStringParameter Name="recID" QueryStringField="ID" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="LiveAccess" Type="String"/>
<asp:Parameter Name="DevelopmentAccess" Type="String" />
<asp:Parameter Name="MediaAccess" Type="String" />
<asp:Parameter Name="DoctorAccess" Type="String" />
<asp:Parameter Name="DealerAccess" Type="String" />
<asp:Parameter Name="ContentType" Type="String" />
<asp:Parameter Name="ProductType" Type="String" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Subtitle" Type="String" />
<asp:Parameter Name="ReviewDate" Type="String" />
<asp:Parameter Name="ReleaseDate" Type="String" />
<asp:Parameter Name="ObsoleteDate" Type="String" />
<asp:Parameter Name="Keywords" Type="String" />
<asp:Parameter Name="Copy" Type="String" />
<asp:Parameter Name="Notes" Type="String" />
<asp:Parameter Name="WriterName" Type="String" />
<asp:Parameter Name="WriterEmailAddress" Type="String" />
<asp:Parameter Name="Language" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
</form>
</asp:Content>

View 1 Replies View Related

Sql Image Upload And Retrieval?

Apr 9, 2006

Hi all, I dont know if anyone here can help me...I am using ASP.NEt with VB.Net and SQL Sever...What I am trying to do is create a system whereby it allows users to upload images into sql server, and thereon later retireve this image.I used a book called The Ultimate VB.Net and ASP.Net Code Book, and it basically gave me the code below to upload and retrieve images.  I seem to have managed to allow the uploading of images, with them being stored as <byte> in my database, thought I have no idea how to retrieve them...Does anyone have any ideas???Here is the code I followed.. :"Storing Uploaded Files in Your Database First, a few tips on storing files inside your SQL Server database.For convenience, you’ll really need to store at least three bits of information about your file to get it out in the same shape as you put it in. I’d suggest “dataâ€? (a field that will hold your actual file as a byte array, data type “imageâ€?), “typeâ€? (a field to hold details of the type of file it is, data type “varcharâ€?), and “lengthâ€? (a field to hold the length in bytes of your file, data type “intâ€?). I’d also recommend “downloadNameâ€?, a field to hold the name that the file had when it was uploaded, data type “varcharâ€?. This helps suggest a name should the file be downloaded again via the Web.The problem you have is translating the information from the File Field control into an acceptable format for your database. For a start, you need to get your file into a byte array to store it in an image field. You also need to extract the file type, length, and the download name. Once you have this, set your fields to these values using regular ADO.NET code.So, how do you get this information? It’s simple: just use the following ready-to-run code snippets, passing in your File Field control as an argument. Each function will return just the information you want to feed straight into your database, from a byte array for the image field to a string for the file type.Public Function GetByteArrayFromFileField( _     ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) _     As Byte()     ' Returns a byte array from the passed     ' file field controls file     Dim intFileLength As Integer, bytData() As Byte     Dim objStream As System.IO.Stream     If FileFieldSelected(FileField) Then         intFileLength = FileField.PostedFile.ContentLength         ReDim bytData(intFileLength)         objStream = FileField.PostedFile.InputStream         objStream.Read(bytData, 0, intFileLength)         Return bytData     End If End Function Public Function FileFieldType(ByVal FileField As _   System.Web.UI.HtmlControls.HtmlInputFile) As String     ' Returns the type of the posted file     If Not FileField.PostedFile Is Nothing Then _       Return FileField.PostedFile.ContentType End Function Public Function FileFieldLength(ByVal FileField As _   System.Web.UI.HtmlControls.HtmlInputFile) As Integer     ' Returns the length of the posted file     If Not FileField.PostedFile Is Nothing Then _       Return FileField.PostedFile.ContentLength End Function Public Function FileFieldFilename(ByVal FileField As _   System.Web.UI.HtmlControls.HtmlInputFile) As String     ' Returns the core filename of the posted file     If Not FileField.PostedFile Is Nothing Then _       Return Replace(FileField.PostedFile.FileName, _       StrReverse(Mid(StrReverse(FileField.PostedFile.FileName), _       InStr(1, StrReverse(FileField.PostedFile.FileName), ""))), "") End Function Sorted! One question remains, however. Once you’ve got a file inside a database, how do you serve it back up to a user? First, get the data back out of SQL Server using regular ADO.NET code. After that? Well, here’s a handy function that’ll do all the hard work for you. Simply pass the data from your table fields and hey presto:Public Sub DeliverFile(ByVal Page As System.Web.UI.Page, _   ByVal Data() As Byte, ByVal Type As String, _   ByVal Length As Integer, _   Optional ByVal DownloadFileName As String = "")     ' Delivers a file, such as an image or PDF file,     ' back through the Response object     ' Sample usage from within an ASP.NET page:     ' - DeliverFile(Me, bytFile(), strType, intLength, "MyImage.bmp")     With Page.Response         .Clear()         .ContentType = Type         If DownloadFileName <> "" Then             Page.Response.AddHeader("content-disposition", _               "filename=" & DownloadFileName)         End If         .OutputStream.Write(Data, 0, Length)         .End()     End With End Sub Simply pass your byte array, file type, and length, and it’ll send it straight down to your surfer. If it’s an image, it’ll be displayed in the browser window. If it’s a regular file, you’ll be prompted for download.If it’s made available for download, this function also allows you to specify a suggested download file name, a technique that many ASP.NET developers spend weeks trying to figure out. Easy! Working with Uploaded Images Whether you’re building the simplest of photo album Web sites or a fully fledged content management system, the ability to work with uploaded images is a vital one, and with ASP.NET, it’s a real doddle.The following code snippet shows you how, by example. It takes a data stream from the File Field control and converts it into an image object, adding simple error handling should the uploaded file not actually be an image. The code then uses this image object to extract a few core details about the file, from its dimensions to file type:' Get data into image format Dim objStream As System.IO.Stream = _   MyFileField.PostedFile.InputStream Dim objImage As System.Drawing.Image Try     ' Get the image stream     objImage = System.Drawing.Image.FromStream(objStream) Catch     ' This is not an image, exit the method (presuming code is in one!)     Exit Sub End Try ' Filename Dim strOriginalFilename As String = MyFileField.PostedFile.FileName ' Type of image Dim strImageType If objImage.RawFormat.Equals(objImage.RawFormat.Gif) Then     strImageType = "This is a GIF image" ElseIf objImage.RawFormat.Equals(objImage.RawFormat.Bmp) Then     strImageType = "This is a Bitmap image" ElseIf objImage.RawFormat.Equals(objImage.RawFormat.Jpeg) Then     strImageType = "This is a JPEG image" ElseIf objImage.RawFormat.Equals(objImage.RawFormat.Icon) Then     strImageType = "This is an icon file" ElseIf objImage.RawFormat.Equals(objImage.RawFormat.Tiff) Then     strImageType = "This is a TIFF file" Else     strImageType = "Other"   End If   ' Dimensions   Dim strDimensions As String   strDimensions = "Width in pixels: " & objImage.Width & _     ", Height in pixels: " & objImage.Height   ' Send raw output to browser   Response.Clear()   Response.Write(strOriginalFilename & "<p>" & strImageType & _     "<p>" & strDimensions)   Response.End() "For some reason the retrieval code isnt working for me..Can anyone provide any help? even if it means using another method?

View 1 Replies View Related

Image Upload Problem Into Database

May 3, 2007

Hi guys,I'm currently trying to insert image into my SQL db.  I have tried a number of methods that were posted online, and so far with no luck.My current code reads:                     Dim conn As New Data.SqlClient.SqlConnection()                    conn.ConnectionString = ConfigurationManager.ConnectionStrings("MainDBConnection").ToString                    conn.Open()                    Dim cmd As New Data.SqlClient.SqlCommand("SP_SAVEImage", conn)                    cmd.CommandType = Data.CommandType.StoredProcedure                    Dim nUserID As New Data.SqlClient.SqlParameter("@nUserID", Data.SqlDbType.Int)                    nUserID.Value = "1"                    Dim nAlbumID As New Data.SqlClient.SqlParameter("@nAlbumID", Data.SqlDbType.Int)                    nAlbumID.Value = "1"                    Dim sDescription As New Data.SqlClient.SqlParameter("@sDescription", Data.SqlDbType.VarChar, 50)                    sDescription.Value = "image1"                    Dim sImageName As New Data.SqlClient.SqlParameter("@sImageName", Data.SqlDbType.VarChar, 50)                    sImageName.Value = sImageName                    Dim sImageType As New Data.SqlClient.SqlParameter("@sImageType", Data.SqlDbType.VarChar, 50)                    sImageType.Value = fileType                    Dim sImageData As New Data.SqlClient.SqlParameter("@sImageData", Data.SqlDbType.Image, uploadedFile.Length)                    sImageData.Value = uploadedFile                    cmd.Parameters.Add(nUserID)                    cmd.Parameters.Add(nAlbumID)                    cmd.Parameters.Add(sDescription)                    cmd.Parameters.Add(sImageName)                    cmd.Parameters.Add(sImageType)                    cmd.Parameters.Add(sImageData)                    Dim reader1 As Data.SqlClient.SqlDataReader                    reader1 = cmd.ExecuteReaderRunning through debug, everything runs up until the last line, where an error is caught saying : Failed to convert parameter value from a SqlParameter to a String I reckon it's to do with the input sImageData being input as a byte array - but I can't seem to find a way around it. Any help greatly appreciated!! 

View 2 Replies View Related

How To Upload Image To Sql Server Database?

Sep 1, 2005

Is there method that an image file upload to sql server database? or transfer th link to database?

View 3 Replies View Related

Upload Image To Sql2000 Problem

Nov 17, 2005

I am using asp.net+sql server 2000 to upload a image to database.the wired thing is, if I upload images from some folder like my documents/my pictures, the error message like 'String or binary data would be truncated' will be there and fail to upload. but I move those images to another folder like c: emp and then upload again, it works fine.
any ideas? thanks a lot.

View 2 Replies View Related

Upload Files To Image Column

Nov 6, 2006

Anyone have any luck using "Upload multiple files to SQL Server Image column"
www.databasejournal.com/features/mssql/article.php/3444771

View 3 Replies View Related

How To Upload An Image Into SQL Server 2000 Per T-SQL

Feb 11, 2008

Hi,

SQL Server 2008 on its way. 2005 should be standard. But sometimes you have SQL Server 2000.
How can I upload an image into the SQL Server 2000 with an T-SQL Statement?

In SQL Server 2005 I would write something like this:
Code Snippet
INSERT INTO ReportingImages
(Name, Img)
SELECT 'UploadTest',
BulkColumn FROM OPENROWSET(
Bulk 'C:ds9.png', SINGLE_BLOB) AS BLOB

That doesnt work under 2000.

What about uploading to the SQL Server 2000 and an Image-Datatype?

Is it even possible in T-SQL without a Web-Service or C#/VB-written tool?

-------------------------------
Update: Thank you all for your answers. We'll use a tool then.

View 5 Replies View Related

How To Upload A Image And Store Into Database And Retrive

Jan 21, 2008

I am using FileUpload method in tools box and i want to store the uploaded image into database.
but when debuging it will shows an error like: Operand type clash: sql_variant is incompatible with image
this is the code for "upload" button.Protected Sub uploadbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uploadbtn.Click
If FileUpload1.HasFile Then
TryFileUpload1.SaveAs("C: emp" & FileUpload1.FileName)
Label1.Text = "File name: " & FileUpload1.PostedFile.FileName & "<br>" & "File Size: " & FileUpload1.PostedFile.ContentLength & "kb<br>" & "Content Type: " & FileUpload1.PostedFile.ContentTypeCatch ex As Exception
Label1.Text = "ERROR: " & ex.Message.ToString
End Try
Else
Label1.Text = "You have not specified a file"
End If
Try
SqlDataSource1.Insert()
Label2.Text = "picture is saved"Catch ex As Exception
Label2.Text = ex.Message.ToString
End Try
End Sub

View 3 Replies View Related

How To Upload Image From Local Drive To Mssql?

Apr 3, 2004

for example : there is a bitmap file in my harddisk "c:a.bmp".
How can I upload it to the db with the field "image" via mssql command,
my DB is mssql database.

I am now using c# based project

thx

View 1 Replies View Related

Save Upload Image To Db Using Stored Procedure Problem

Jul 15, 2004

I am trying to save an uploaded image and its associated info to sql server database using a stored procedure but keep getting trouble. When trying to save, the RowAffected always return -1. but when i debug it, I dont' see problem both from stored procedure server
explore and codebehind. it looks to me every input param contains correct value(such as the uploaded image file name, contentType and etc). well, for the imgbin its input param value returns something like "byte[] imgbin={Length=516}". Below is my code, could anyone help to point out what did I do wrong?
Thank you.

================================================
CREATE PROCEDURE [dbo].[sp_SaveInfo]
(
@UserID varchar(12),
@Image_FileName nvarchar(50),
@Image_ContentType nvarchar(50),
@Image_ImageData image,
@Create_DateTime datetime)

AS
set nocount on

insert ExpertImage(UserID, Image_FileName, Image_ContentType, Image_ImageData, Image_ReceiveDateTime)
values(@UserID, @Image_FileName, @Image_ContentType, @Image_ImageData, @Create_DateTime)
GO

private void Submit1_ServerClick(object sender, System.EventArgs e)
{
if(Page.IsValid)
{
Stream imgStream = File1.PostedFile.InputStream;
int imgLen=File1.PostedFile.ContentLength;
string imgContentType = File1.PostedFile.ContentType;
string imgName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\") + 1);
byte[] imgBinaryData = new byte[imgLen];
int n=imgStream.Read(imgBinaryData, 0, imgLen);
int RowsAffected = SaveInfo(imgName,imgBinaryData, imgContentType);
if(RowsAffected > 0)
{
..
}
else
{
..
}
}
}

public int SaveInfo(string imgName, byte[] imgbin, string imgcontenttype)
{

SqlConnection objConn = new DSConnection().DbConn;
SqlCommand objCMD = new SqlCommand("sp_SaveInfo", objConn);
objCMD.CommandType = CommandType.StoredProcedure;

objCMD.Parameters.Add("@UserID", SqlDbType.VarChar, 12);
objCMD.Parameters["@UserID"].Value = txtMemberID.Text.ToString();
objCMD.Parameters["@UserID"].Direction = ParameterDirection.Input;

objCMD.Parameters.Add("@Create_DateTime", SqlDbType.DateTime);
objCMD.Parameters["@Create_DateTime"].Value = DateTime.Now.ToLongTimeString();
objCMD.Parameters["@Create_DateTime"].Direction = ParameterDirection.Input;

objCMD.Parameters.Add("@Image_FileName", SqlDbType.NVarChar, 50);
objCMD.Parameters["@Image_FileName"].Value = imgName;
objCMD.Parameters["@Image_FileName"].Direction = ParameterDirection.Input;
objCMD.Parameters.Add("@Image_ContentType", SqlDbType.NVarChar, 50);
objCMD.Parameters["@Image_ContentType"].Value = imgcontenttype;
objCMD.Parameters["@Image_ContentType"].Direction = ParameterDirection.Input;

objCMD.Parameters.Add("@Image_ImageData", SqlDbType.Image);
objCMD.Parameters["@Image_ImageData"].Value = imgbin;
objCMD.Parameters["@Image_ImageData"].Direction = ParameterDirection.Input;


int numRowsAffected = objCMD.ExecuteNonQuery();
return numRowsAffected;

}

View 1 Replies View Related

Image Display Only Once

Dec 17, 2007

Hello.

I have a report in RS2005.

I added an image to my report (drag and drop the image from the solution explorer to my report).

When the report first show I can see the image but after I click once on a column arrow to sort it - The image is replace by a small red X.

I checked to see that the image was uploaded to the same directory as my report.

Any idea way is that?

Thanks in advanced.

View 2 Replies View Related

Display Image Stored In SQL

Sep 9, 2004

Hello group
Is there a way to display an image stored in SQL without using a datagrid? I am using vb, the very few examples I do find open the image in a window by its self. Also is there a way find the height and width of an image stored in the database and the ability to change the image size? Example – when an image is uploaded to the database I would like a thumbnail to be created and also stored in the database. Any ideas please help.
Michael

View 1 Replies View Related

Image Does Not Display On Report

Apr 17, 2007

I have a simple report that has nothing but an image. The image is part of the project. The image displays in the VS 2005 dev environment when report is previewed. But when deployed and run on the report server website, it does not display. If the report is print previewed or exported to Excel, the image displays. I've set my browser to have the least security as possible but still to no avail (made the website trusted as well). The server is running SQL Server 2005 SP2. My browser is IE7. Can anyone please help? Thanks.

View 1 Replies View Related

I Can't Display Image On My Report

Jan 22, 2008

Hi.
I used insert command to insert a image file to my SQL like
insert [ABC].[dbo].[Itemimage] value ('12345', 'c:Imagepicture1.jpg'). but when I use report
design to read this DB, I can't show this image in my report.
Does anybody can help me to find out my error?

Thanks

View 2 Replies View Related

Direct Display Of SQL Image Field

Aug 3, 2004

Hi

I have a SQL 2000 table in which pictures are stored as an Image column. I want to display then onto a c# aspx webpage without storing them to disk.
What is the best way to read and display the pictures?
In classic ASP I used to do this:
Response.ContentType = "image/jpeg"
Response.BinaryWrite rs.fields("ThisImage")
but I can't get this to work in c#.

View 2 Replies View Related

Retrieve An Image, For Display On Website?

Feb 25, 2006

How would I do if I want to make a query that returns an image, which in turn should be displayed on a webpage?

View 2 Replies View Related

Server Error: Object Reference Not Set To An Instance Of An Object. Trying To Upload Image In Database

Dec 17, 2007

Does any one has any clue for this error ? I did went through a lot of articles on this error but none helped . I am working in Visual studie 2005 and trying to upload image in sql database through a simple form. Here is the code
 
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;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.IO;
public partial class Binary_frmUpload : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e)
{
}protected void btnUpload_Click(object sender, EventArgs e)
{if (FileUpload.HasFile == false)
{
// No file uploaded!lblUploadDetails.Text = "Please first select a file to upload...";
}
else
{string str1 = FileUpload.PostedFile.FileName;
 string str2 = FileUpload.PostedFile.ContentType; string connectionString = WebConfigurationManager.ConnectionStrings["GSGA"].ConnectionString;
//Initialize SQL Server Connection SqlConnection con = new SqlConnection(connectionString);
//Set insert query string qry = "insert into Officers (Picture,PictureType ,PicttureTitle) values(@ImageData, @PictureType, @PictureTitle)";
//Initialize SqlCommand object for insert. SqlCommand cmd = new SqlCommand(qry, con);
//We are passing Original Image Path and Image byte data as sql parameters. cmd.Parameters.Add(new SqlParameter("@PictureTitle", str1));
cmd.Parameters.Add(new SqlParameter("@PictureType", str2));Stream imgStream = FileUpload.PostedFile.InputStream;
int imgLen = FileUpload.PostedFile.ContentLength;byte[] ImageBytes = new byte[imgLen]; cmd.Parameters.Add(new SqlParameter("@ImageData", ImageBytes));
//Open connection and execute insert query.
con.Open();
cmd.ExecuteNonQuery();
con.Close(); //Close form and return to list or images.
 
}
}
}
 
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:



Line 32:
Line 33: string str2 = FileUpload.PostedFile.ContentType;
Line 34: string connectionString = WebConfigurationManager.ConnectionStrings["GSGA"].ConnectionString;
Line 35:
Line 36: //Initialize SQL Server Connection Source File: c:UsersManojDocumentsVisual Studio 2005WebSitesGSGABinaryfrmUpload.aspx.cs    Line: 34  
Stack Trace:




[NullReferenceException: Object reference not set to an instance of an object.]
Binary_frmUpload.btnUpload_Click(Object sender, EventArgs e) in c:UsersManojDocumentsVisual Studio 2005WebSitesGSGABinaryfrmUpload.aspx.cs:34
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

View 2 Replies View Related

Inserting Image File Into Image Column In DB

Sep 20, 2006

I have inherited a VS 2005 database with a table that has a column of type IMAGE. I need to change the image for one of the rows in the table. I have the new image in a *.PNG file on my C: drive. What is the correct method for inserting this file into the IMAGE column.

Many thanks!

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

Unable To Display Image Loaded Into SQL Server

Dec 16, 2006

Hello, I'm using a multipart/form-data upload to put an image into SQLServer, and it appears to be working, but I'm unable to display theimage. All I'm getting is the text of the URL we're on in Firefox anda missing image icon in IE! Any ideas why this isn't working? Here'sthe image upload code:Dim intImageSize As Int64Dim strImageType As StringDim ImageStream As StreamintImageSize = Picture.PostedFile.ContentLengthstrImageType = Picture.PostedFile.ContentTypeImageStream = Picture.PostedFile.InputStreamDim ImageContent(intImageSize) As ByteDim intStatus As IntegerintStatus = ImageStream.Read(ImageContent, 0, intImageSize)'make connection, write SPs, open connection, etc.TrydbComm.ExecuteNonQuery()Connect.closeCatch SQLexc As SqlExceptionResponse.Write("Insert Failed. Error Details are: " &SQLexc.ToString())End Try--------------And now the display code:'make connection, then SELECT Image, Imagetype FROM Pets WHERE[User]=@user AND Petn=@petn'stored proceduresDim Reader As SqlDataReaderReader = dbComm.ExecuteReader(CommandBehavior.CloseConnecti on)If Reader.read=True ThenResponse.ContentType = Reader(1)Response.BinaryWrite(Reader(0))ElseEnd IfReader.closeConnect.close----------------------------Thanks.

View 1 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

Display Image To ASP .NET From Bynary Data MSSQL 2000

May 16, 2007

Hi I have image in database sql server 2000 and want to display in ASP .net page. I make the memorystream from that data and write directly to page using Response.Write([bynary stream]) but U know it only display one image and other HTML is gone.
 Normaly a HTML or ASP.net page will display image using local files like this <img src=.............> but how if I want to display it from memory stream that doesn't have physically in storage ? Or should I save that binary to storage first and then reference it ?
So anyone that have solution for this problem please help me  how to this thing ............

View 3 Replies View Related

Unable To Display Report Header Image When Deployed

Apr 17, 2007

Hello All,



I am unable to display report header when I deploy the reports on report server (Internet). However, they look perfect when previewed in the BI studio. Any clue where could be the problem?



Thanks in Advance!

Rashi

View 3 Replies View Related







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