Image File Save To DB
Jul 13, 2005How to save image file to database?
Which control use best?
How to save image file to database?
Which control use best?
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
When I am trying to save byte[] of an image to SQL server which is having an image column, I am getting an error like this " A severe error occured on the current command. The results, if any, should be discarded.". I am trying to save through a stored procedure.
In the sp also, the datatype is image.
Can you give a reply to this?
Hi,
I have to store images in database. I have a table which contains field picture which is an image.
How can I do this using C# ?
In Visual Studio .NET i found a code how to obtain BLOB values from the database but I do not know how to do upload an image to the database.
Thanks in advance for your help.
Rafi
i'm trying to read an image file from a database(ms-sql, .mdf) with type image. Anyone have any ideas on how to do this? I have a table adapter created but could not assign it to my byte[] variable. Thanks in advance.
View 1 Replies View RelatedI have a table with two fields Part_num and Pic in SQL server 2000 Pic is of Image type. Is there a way I can save images for each part_num using Query analyzer?
View 6 Replies View RelatedI 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;
}
I have to access a web service where I pass in a product number and it produces an XML result with an /image section where it has a long string (base64?) I am trying to call the web service and save the image to the OS.
I am trying to get the result into a variable and save it to disk with the itemno.jpg as the name
This is a sample file I get back..
<NewDataSet>
<Table>
<ITEMNO>2065</ITEMNO>
<Image>/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNr ... removed since too long for post ...</Image>
<ImageDate>2015-04-15T00:00:00+00:00</ImageDate>
</Table>
</NewDataSet>
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!
Hi,
I use the DTS 2000 Migration Wizard to migrate one of the DTS 2000 packages to SSIS. The migration failed with the following error message:
LogID=17
#Time=6:31 PM
#Level=DTSMW_LOGLEVEL_ERR
#Source=Microsoft.SqlServer.Dts.MigrationWizard.Framework.Framework
#Message=Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException: Failed to save package file "C:Documents and SettingsfuMy DocumentsVisual Studio 2005ProjectsKORTONKORTONProcessCubesMF.dtsx" with error 0x80070002 "The system cannot find the file specified.".
---> System.Runtime.InteropServices.COMException (0xC001100E): Failed to save package file "C:Documents and SettingsfuMy DocumentsVisual Studio 2005ProjectsKORTONKORTONProcessCubesMF.dtsx" with error 0x80070002 "The system cannot find the file specified.".
at Microsoft.SqlServer.Dts.Runtime.Wrapper.ApplicationClass.SaveToXML(String FileName, IDTSPersist90 pPersistObj, IDTSEvents90 pEvents)
at Microsoft.SqlServer.Dts.Runtime.Application.SaveToXml(String fileName, Package package, IDTSEvents events)
--- End of inner exception stack trace ---
at Microsoft.SqlServer.Dts.Runtime.Application.SaveToXml(String fileName, Package package, IDTSEvents events)
at Microsoft.SqlServer.Dts.MigrationWizard.DTS9HelperUtility.DTS9Helper.SaveToXML(Package pkg, String sFileLocation)
at Microsoft.SqlServer.Dts.MigrationWizard.Framework.Framework.StartMigration(PackageInfo pInfo)
Looking at the call stack, it looks like COM wrapper fails on SaveToXML. Can someone tell me how I should workaround this problem?
Thanks,
Bobby Fu
Every day we are restoring prod DB in Development env. I need to save before restore users stored proc,
restore DB and after create SP from file.
Thanks.
According to the help for SSIS, one method of deploying an SSIS package
to a SQL Server,
http://msdn2.microsoft.com/en-us/library/ms137565.aspx, is to use the
File...Save a Copy of <package file> as... menu option.
I don't have that menu option at all. And yes, the package is in
focus. My save menu options are simply; Save Selected, Save
<package file> As... and Save All.
I am using Version 9.00.1399.00 of the SSIS Designer.
At one time I did have the Management Studio's CTP installed.
However it was uninstalled before installing the tools from the
Standard Edition. (it would seem like not completely however)
Your help would be greatly appreciated. Thanx much.
p.s. Almost forgot to mention... I am already aware of using the
DTSInstall utility as a workaround. It should be noted, however,
that despite enabling the "CreateDeploymentUtility" property, the
DTSInstall.exe is not copied to the binDeployment directory.
i'm trying to save data to an XML file from an OLE DB source using the "For XML" clause in the SQL command. Do I need to use a flat file connection manager or a raw file connection manager? And what destination do I use?
View 3 Replies View RelatedI haven't downloaded nor installed it but I have some general questions about it:
*Can I store a SQL Server-Express Database as a file, so that the Users can easily back it up or use my application as a portable one
*Do the enduser have to install SQL Server Express or any addition when I'm programming for the .Net Framework 3.5?
I'm looking forward to your answer!
I have the need to allow a user to upload a file via the web and then save it into a database. THen I also need to be able to retrieve the file for download.
Can someone give me guidance as to code or a sample on how to do this.
Thanks.
I have a asp.net application where i can choose to save any file(could be jpg or dat or txt or xml etc etc) into a table.So far,i've manage to save it into an SQL server table in a column(set to Image datatype).But when i get the data from the table,put it into a byte array and recreate it.I notice that the files can be recreated correctly if they are of type .txt files.But jpg files can't be recreated and trying to open the jpg files gives an error.I don't think it is the file saving that is the problem since any files can be save.Rather it is the file recreating that is the problem.Can anyone help?
View 3 Replies View RelatedNeed advise on how to save objects like this in a sql2005 database, so they can be rendered to users thru a gridview control. Heard of saving a reference to location, but wondering if the entire object can be saved and served up with it's related data.
Thanks for your time.
Is it possible to save a report as a CSV when the report is run without the user having to export the file? I need to save the report to a server location without the end user having to specify where.
View 3 Replies View Relatedhi all.
i have a simple table with 2 fields:
1. name
2. file
i have an xml file -> zz.mxl
how do i save this file to the db in a stored proc?
how do i call this from ado.net?
I have a server with MSDE 2000 installed onto it. I also installed SQLEXPR_TOOLKIT.EXE . Now there is a DTS package present on that server saved in the DB. How can I alter that package? And if that's not possible: how can I save the package to a file so I can transfer that file to my development machine?
Thanks in advance,
Stijn Verrept.
Hi,All,
How can i save one file from one location to other location(save as) using Asp.Net code.
Any body pls send Source code.
Regards
how do i write a select query which will return all my data into an excel file or an xml file or txt file?
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
Hi, I have a table which holds raw xml in a field with type XML. How do I export that XML field to an XML file? Thanks Bones
View 6 Replies View RelatedHi,
I want to upload a file (e.g. .xls, .pdf, .doc) and save into the Sql Server 2000 database through the web interface, and then to download this file. Any idea???
HI,
I was wondering if it is possible to save the database E-R diagram to file in
MS SQL server 7?
Regards
Guy
I want to write a small program (maybe just a stored procedure) that will save the results and column names of a simple query to CSV file. This will then be copied onto disk and distributed to user who'll use Excel or a similar package to open the CSV file.
Any suggestions as to the best way to achieve this? I was considering using a view and then BCP but I have problems then when trying to open the CSV file in excel (or other spreadsheet package). Doesn't like the datatypes and so on.
Is there a simple way to do this? And is it possible to save the results in such a way that Excel will choose the right datatypes for the columns. (not convert varchar's like '000122' to numbers.)
I would like to create a SQL job that runs a basic query monthly and saves the results as a .xls file and emails the results to a user. I've been unsuccessful with sp_send_dbmail in that the output file is always a single column. Any suggestions?
Thanks, Dave
Hello,
I am working on a ASP.NET 2.0 project with an SQL 2005 database.
I created a documents table with various columns including:
DocumentId and DocumentUrl
My documents will always be PDF's of SWF's (Flash Paper Files)
I will need to display this files in my web pages.
My question is:
Should I save the DocumentUrl in the database or should I save the file itself in the database?
And how can I save files in an SQL 2005 database?
Thanks,
Miguel
Want to save the result of a query in sql server express to a text file or any other file.
anujahanvi
Microsoft,
We need some help to resolve an issue. We want to load and save the last version of a DTS File but using this command:
EXEC @rc = sp_OAMethod @object, 'SaveToStorageFile', NULL, @Path_Log_Save_DTS
we always get all versions of the DTS File. Could you help us to Load or Save only the last version of the file? Is there any option of this procedure sp_OAMethod (or other) that solve the problem?
Thanks,
Regards,
I am just beginning to work on an ETL project at a new client site using their computers. They are an IT department new to SQL Server. We have SQL Server 2005 up and running, no probkem. But I get that error when I try to add a new package to an SSIS project. The error number is 0x8002801D "Library Not Registered". I did see the post about the MSXML DLL files and when I try to load an existing package I get 3 errors regarding XML - stating that the MSXML binaries may not be installed or registered properly. I searched and found the MSXML3 & 6 DLLs but the MSXML4.DLL appears to be missing. If I repair the installation, will this fix it? BTW - the MSXML 6.0 Parser did show as being installed in Add/Remove Programs.
Thanks for you help!
Hi All,
I'm developing a credit card application, and would like to store some sensitive data in a table temporarily, but be absolutely positive it either never goes into the log file in the first place, or is securely deleted from the log file when I delete the data. There's millions of other bits of data in the log, so truncating or otherwise disposing of the whole log is not an option.
In particular, I'm capturing the credit card mag stripe at the beginning of a transaction, and saving it while the work is done to complete the transaction. (ie, a pilot walks in, says "Top off the G4 with JetA, here's my card, have it ready when I get back.") We want to save the swipe info for maybe a couple of hours (it is encrypted during this time), use it for the authorization, then throw it away as per credit card industry rules.
Is there any way I can save the encrypted text string in a normal MSSQL field (Varchar(200)), have it stay around for a few hours as the user logs in and out of the database, then delete the record and be sure it's nowhere in the log?
TIA,
George Lehmann
Horizon Business Concepts, Inc.
Broken Arrow, OK