Saving Picture In A SQL Database (ASP.NET 2.0/C#)
Dec 1, 2005
I'm looking for information that could tell me how to saving picture in a SQL database. The site is build on asp.net 2.0 and c#, and I'm using Visual Web Developer 2005 Express Edition. I would be thankful for some help.
View 1 Replies
ADVERTISEMENT
Oct 13, 2007
I am trying to save an uploaded picture filepath to a sql database record. The record that the filepath will be saved to will be the record determined by the logged in userid. I get an error stating Object not set to an instance of an object. This is my code for when the upload button is hitProtected Sub uploadbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uploadbutton.Click
If UploadTest.HasFile = False Then
' No file uploaded!
UploadDetails.Text = "Please first select a file to upload..."
Else
' Display the uploaded file's detailsUploadDetails.Text = String.Format( _
"Uploaded file: {0}<br />" & _"File size (in bytes): {1:N0}<br />" & _"Content-type: {2}", _
UploadTest.FileName, _
UploadTest.FileBytes.Length, _
UploadTest.PostedFile.ContentType)
' Save the fileDim filePath As String = Server.MapPath("~/ProfilePictures/" & UploadTest.FileName)
UploadTest.SaveAs(filePath)Dim datasources1 As New SqlDataSourcedatasources1.ConnectionString = ConfigurationManager.ConnectionStrings("aspnetdb_connection").ToString()
datasources1.UpdateCommandType = SqlDataSourceCommandType.Text
Dim myUserID As String = Membership.GetUser().ProviderUserKey.ToStringdatasources1.UpdateParameters("userid").DefaultValue = myUserID
datasources1.UpdateCommand = "UPDATE into profile_details (pic) VALUES (@filepath) WHERE ([UserId] = @UserId)"
End If
End Sub
Any ideas on what i need to do to fix this?
View 5 Replies
View Related
Apr 3, 2004
can ne 1 specify, how to insert a picture into a PostgreSql DB?
pl tell which data type to use and how can i display the picture in my client app
View 1 Replies
View Related
Dec 28, 2006
Can i put picture in sql server database but not filename and path. I wantto put complete picture in field in database. Is it possible?
View 2 Replies
View Related
Apr 9, 2007
Hi,
My question is how can i get a page show all of my pictures i got in folder c:..Images? by using Database. Becouse I want some of the pictures to be shown in one page for theirselves.
Database looks like:
ID | Pname | Pact |
1 | picture1 | Yes |
2 | picture2 | No | etc.
Now i want picture 1 and 2 to be shown in my Allpictures.aspx
I tried by using <asp:repeater...>... But i got a problem when i wanted the <img src=<%#EVAL(Pname)/>... becouse i cant do it that way...
Thanks,
Even Knutli
View 2 Replies
View Related
Jun 19, 2005
How to insert a picture into SQL Server 2000 table?
I want
1)Table structure.
2)Insert statement.
3)One example.
View 1 Replies
View Related
Oct 24, 2000
How do I store an image/photo/picture in a database?
I have a database called database1 with a table called table1 like:
Table1:
Personid Name1 Name2 Address
and I want to stora a picture of the person in the database (SQL Sever 7) c:picture.jpg. How could I do that? I would like to use a stored procedure to do it. Something with BLOB?bulk insert? how does it work?
Thanks for you help!
//Carl
View 1 Replies
View Related
Jun 17, 2007
Hi,
I am new to SQL Server and I have got this problem and I am wondering if anyone could provide me with a solution, please.
I created a Product database table using Visual Basic 2005 Express and SQL Server 2005 Express. I have just added a new column [Picture] with IMAGE datatype to the database table, which of course, should store an image or picture of a product. I am writing to kindly ask you guys for help.
i) How do I store a picture or image for each record of this column [Picture] of database table? I have tried and all that I can see is < binary data > in the picture column, and when I start the VB 2005 Express form is a blank picture box!
ii) How do I get this image to display on Visual Basic 2005 Express form, so that when a product is selected the product image is displayed too? All text data appears but not the picture!
Your help much appreciated. Thanks.
Paul
View 3 Replies
View Related
Feb 2, 2008
Hi,
I have a scenario where I want the current User to add details regarding their house in to my 'Property' table in my database and also store their uploaded picture in the same tabe when they press the 'Add Property' button. I also want to store the current Users ID in the 'Property' table so the property being added is assigned to the current user. Can anyone help me with the implementation of this? Here is the code I have so far:
property.aspx page:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<span style="font-size: 16pt; font-family: Bradley Hand ITC"><strong>Add Property</strong></span><table style="border-right: silver 3px outset; border-top: silver 3px outset; left: 337px;
border-left: silver 3px outset; border-bottom: silver 3px outset; position: relative;
top: 9px">
<tr>
<td colspan="2">
<strong><span style="font-size: 14pt; font-family: Bradley Hand ITC">
Address</span></strong></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="TownLabel" runat="server" Font-Bold="False" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Town:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="TownTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="CityLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="City:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="CityTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="CountyLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="County:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="CountyTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="CountryLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Country:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="CountryTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="PostcodeLabel" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Postcode:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="PostcodeTextBox" runat="server"></asp:TextBox></td>
</tr>
</table>
<asp:Button ID="AddButton" runat="server" Text="Add Property" style="left: 378px; position: relative; top: 66px" /><tablestyle="border-right: silver 3px outset; border-top: silver 3px outset; left: 648px;
border-left: silver 3px outset; border-bottom: silver 3px outset; position: relative;
top: -190px">
<tr>
<td style="width: 186px">
<span style="font-size: 14pt; font-family: Bradley Hand ITC"><strong>Property Description</strong></span></td>
</tr>
<tr>
<td style="width: 186px">
<asp:TextBox ID="DescriptionTextBox" runat="server" Height="172px" Width="233px" TextMode="MultiLine"></asp:TextBox></td>
</tr>
</table><asp:FileUpload ID="PropertyPicture" runat="server" Style="left: 356px; position: relative;
top: -214px" />
<asp:SqlDataSource ID="AddProperty" runat="server" ConnectionString="<%$ ConnectionStrings:My Property PortfolioConnectionString %>"ProviderName="<%$ ConnectionStrings:My Property PortfolioConnectionString.ProviderName %>"
InsertCommand="INSERT INTO Property(User_ID, Property_type, Property_Name, Number_of_Rooms, Sleeps, Town, City, County, Country, Postcode, Description, Facility1, Facility2, Picture)
VALUES (@User_ID, @Property_type, @Property_Name, @Number_of_Rooms, @Sleeps, @Town, @City, @County, @Country, @Postcode, @Description, @Facility1, @Facility2, @Picture)">
<InsertParameters>
<asp:SessionParameter Name="User_ID" />
<asp:ControlParameter ControlID="TypeDropDownList" Name="Property_type" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="PropertyNameTextBox" Name="Property_Name" PropertyName="Text" />
<asp:ControlParameter ControlID="NoOfRoomsDropDownList" Name="Number_of_Rooms" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="SleepsDropDownList" Name="Sleeps" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="TownTextBox" Name="Town" PropertyName="Text" />
<asp:ControlParameter ControlID="CityTextBox" Name="City" PropertyName="Text" />
<asp:ControlParameter ControlID="CountyTextBox" Name="County" PropertyName="Text" />
<asp:ControlParameter ControlID="CountryTextBox" Name="Country" PropertyName="Text" />
<asp:ControlParameter ControlID="PostcodeTextBox" Name="Postcode" PropertyName="Text" />
<asp:ControlParameter ControlID="DescriptionTextBox" Name="Description" PropertyName="Text" />
<asp:ControlParameter ControlID="Facility1DropDownList" Name="Facility1" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="Facility2DropDownList" Name="Facility2" PropertyName="SelectedValue" />
<asp:Parameter Name="Picture" />
</InsertParameters>
</asp:SqlDataSource>
<table style="left: 12px; position: relative; top: -411px; border-right: silver 3px outset; border-top: silver 3px outset; border-left: silver 3px outset; border-bottom: silver 3px outset;">
<tr>
<td colspan="2">
<strong><span style="font-size: 14pt; font-family: Bradley Hand ITC">
Property Details</span></strong></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="PropertyName" runat="server" Font-Bold="False" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Property Name:" Width="101px"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="PropertyNameTextBox" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="NoOfRooms" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="No of Rooms:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="NoOfRoomsDropDownList" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Sleeps" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Sleeps:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="SleepsDropDownList" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Type" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Type:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="TypeDropDownList" runat="server">
<asp:ListItem>Bungelow</asp:ListItem>
<asp:ListItem>Appartment</asp:ListItem>
<asp:ListItem>Flat</asp:ListItem>
<asp:ListItem>Studio</asp:ListItem>
<asp:ListItem>Cottage</asp:ListItem>
<asp:ListItem>House</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Facility1" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Facility 1:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="Facility2DropDownList" runat="server">
<asp:ListItem>Air conditioning</asp:ListItem>
<asp:ListItem>Dishwasher</asp:ListItem>
<asp:ListItem>En-suit</asp:ListItem>
<asp:ListItem>Garage</asp:ListItem>
<asp:ListItem>Garden</asp:ListItem>
<asp:ListItem>Internet</asp:ListItem>
<asp:ListItem>Pool</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 100px"><asp:Label ID="Facility2Label" runat="server" Height="23px" Style="vertical-align: middle;
text-align: right; font-family: 'Goudy Old Style';" Text="Facility 2:" Width="97px"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="Facility1DropDownList" runat="server">
<asp:ListItem>Pool</asp:ListItem>
<asp:ListItem>Air conditioning</asp:ListItem>
<asp:ListItem>Dishwasher</asp:ListItem>
<asp:ListItem>En-suit</asp:ListItem>
<asp:ListItem>Garage</asp:ListItem>
<asp:ListItem>Garden</asp:ListItem>
<asp:ListItem>Internet</asp:ListItem>
</asp:DropDownList></td>
</tr></table>
</asp:Content>
property.aspx.vb page:Partial Class Default2
Inherits System.Web.UI.PageProtected Sub AddButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddButton.Click
AddProperty.Insert()End Sub
End Class
Many Thanks
View 2 Replies
View Related
Apr 8, 2008
I would like to create a table which can store a VLOB or BLOB.. which are pictures and images.. How do I insert them into the database and how do I select them into the data base for playing in a media player
I really do not have a background on this.. much.. I just know how to connect to a database and insert texts.. and updating and stuffs...
View 3 Replies
View Related
Dec 13, 2007
Hi Guys,
I am trying to automate a basic task using SQL Server 2005 Express.
Currently I have a query script that I run and then save the results as a CSV file. I need to do this on a daily basis and so I am looking to find out how best to go about this. There are a multitude of third party tools that claim to be able to do this - can anyone recommend this or enlighten me of the best way to set up this automation.
All ideas gratefully received!
View 1 Replies
View Related
Sep 12, 2007
Hey Guys need your help please!
we are now on our second week back log...
database file is not full and not limited to growth. As a matter of fact batch transactions are done but our proble is very slow. 28 records has been successfully save after 45 mins. Before it's just 5 minutes. Then some other process are not working. Is there anything that I must do? We have 460 tables in our software using SQL server 2000 and our application is using VB 6.0
View 3 Replies
View Related
Apr 10, 2006
Hello,I use SQL Server 2005 Express and I would liketo save on db of mine...Have I only to save the .mdf and .ldf data fileor I need to stop some service or other programs?Can I use some utility to schedule this?ThanksM.
View 4 Replies
View Related
Oct 25, 2006
My install of SQL Server 2005 runs like a dog. The SQL Management Studio splash screen lasts for 10 minutes, then when the Studio window appears it takes another 5 minutes to initialize.
I have SQL server installed on a Germane Server running Windows Server 2K, SP4. It has quad Xeon 2.8 GHz processors with 2GB RAM. 4 300GB drives in a RAID 5 configuration.
I have created 2 databases which I would like to save, uninstall SQL, then reinstall it. (I didn't install it the first time.)
Then load the 2 databases into the new install.
How do I do this?
View 1 Replies
View Related
Jan 20, 2008
Hi.
I am new to SQL Server management.
I created a new database and also a table names customer. Saved my works.
Want ot know where the SQL database file has been saved because i cant find in the the sql server management folder located in my documents.
Also i tried to connect to that database from vb 2008 but in vain. i just cant see the database.
View 4 Replies
View Related
Apr 17, 2007
I have 3 strings delimitted by a * character that I would like to save to a database. Each string will always have the same number of elements.
strUserID = "1*2*3"
strCompanyID="12931*12937*12945"
strCompanyName="International Business Machines, Inc*Ford Motor Company*Delta Airlines"
What I need to do is to save each record like this
INSERT INTO tableA (UserID, CompanyID, CompanyName) VALUES (1, 12931, 'International Business Machines, Inc')
INSERT INTO tableA (UserID, CompanyID, CompanyName) VALUES (2, 12937, 'Ford Motor Company')
INSERT INTO tableA (UserID, CompanyID, CompanyName) VALUES (3, 12945, 'Delta Airlines')
I've done something like this before with a single string, but don't know how to handle 3 of them.
Dim strAlerts As String() = NothingstrAlerts = values.Split(",")Dim s As String For Each s In strAlerts SqlText = "INSERT INTO tableA (UserID, CompanyID, CompanyName) VALUES (" & lblUserID.Text & ", '" & lblCompanyID.Text & "','" & s & "')" cmd = New SqlCommand(SqlText, strSQLConn) cmd.ExecuteNonQuery() Next s
Thanks for any help
View 5 Replies
View Related
May 11, 2007
has anyone got any opinions on the pros/cons of storing mp3 files in the database instead of the file system ?
How could this be done ? Would it be a binary data type ?
View 1 Replies
View Related
Aug 8, 2007
Im using MS visual web developer. I have created a website and used the database they set up by using admin tools. One page requires the take the users comment and to save it into the database. I've tried a formview and connected it to the database which worked. the problem is i cannot save whatever the user types into the textbox. {insert query didnt work with this set up }INSERT INTO aspnet_Membership(Comment) VALUES ('CommentTextBox.Text') Error: cannot set userId or to null. and if i make it allow nulls its going to move on to the next column. I would appreciate some help please. Thank you in advance.
View 4 Replies
View Related
Feb 6, 2008
hi
I have two questions:
1. I want a code to save data typed in a textbox during runtime using SQL server database. The database has a table with several colums where i have to reference the necessary column.
2. Can i use a Gridview to enter data during runtime and save the same data to the database? that is, INSERTING data to the database.
View 1 Replies
View Related
Feb 15, 2006
Hi there,
I have a web page (Visual Studio 2005, Asp.net 2.0) that has a series of textboxes and dropdownlists on it. I want people to be able to enter their information and click submit. When they click the submit button I want their information to save to a Sql Server 2005 database. I am having a lot of trouble finding any information on this topic. If someone could give me some sample code I would really appreciate it.
Thanks
View 2 Replies
View Related
May 19, 2008
I'm using vs2008 programming in the latest vb.net and am pretty new to sql server. I looked up tuts and such to save changes to databases after I understood on how to connect to them get them to display and such. This is my code when I hit the "Save" button. It worked last time I was working on the program, now it doesn't, when I load up the program sometimes (i'm not sure why or under what circumstances) it'll load up the changes I made to the database through the datagrid and saved, but others it won't. What am I doing wrong? Here's my code:
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Try
Me.Validate()
Me.FinancialBindingSource.EndEdit()
Me.FinancialTableAdapter.Update(Me.myDataSet.Financial)
Catch ex As Exception
MsgBox("Update failed")
End Try
End Sub
edit: It saves, but not completely. By that I mean, it'll save, but i'm not sure if it actually saves to the database or not. It will load back up with the data that I modified fine..unless I change any code in the program. Even if I just add a comment, the data reloads with the original data. However, if I don't touch code, it'll save my data fine. Why does it do this?
View 1 Replies
View Related
Jul 20, 2005
I have an application that connects and edits a database's tables.My question is, what is the best way to save who did what changes tothis database? I need to be able to display this in the application.The best way I have thought of so far is, to create a new table with'user', 'date', 'table_name', 'primary_key', 'old field_value' and'new_field_value' fields. Then I can save which table row had beenchanged, by which user and on which date.I'm sure that there is a way to do this in SQL Server, but I'm notsure how.Any help would be appriciated.Jagdip
View 1 Replies
View Related
Oct 24, 2006
Using: Compact Framework 1.0 and SQL Server CE 2.0
i want to save an image to my sql server ce 2.0 database on the device.
In the Compact Framework 1.0 the Image class does not have .FromStream method, and the PictureBox class does not .Save method.
Has anyone done this before in SQL CE 2.0 and CF1.0
Thanks
View 1 Replies
View Related
Nov 11, 2006
Hello,
My english is not the best, but i will try my best.
I want to change the saving folder for the database from my systempartition to my datapartition (from c:labla to d:mydata), but i dont know how. I can see the folder but it is in gray font and unchangeable.
Greetings Thomas
View 1 Replies
View Related
Sep 18, 2007
Heres my requirement from a financial analysis im doing...I have just calculated an industry averages on financial ratios...Now i wanna upload this industry average to the system...so that I can compare it to the individual companies' averages after calculating a particular company's average; meaning i wanna be able to call the industry average of a particular ratio (eg Current Ratio) after calculating a company's corresponding ratio...Is there a code fragment i can use for this ?? Thanks in advance...Adam
View 1 Replies
View Related
Jan 3, 2005
i need to know how can i store my word document into Sql server Database
what data type ?
how can i implenet this using ASP.net
View 3 Replies
View Related
Dec 15, 2007
i work on sql server 2005 at home and have created a database with several tables and dabase diagram , now how do i transfer it to sql server 2000 which i work on at work ,
can somebody point me in the right direction in which this is done
any hlp appreciated
View 1 Replies
View Related
Aug 7, 2007
Hi
Would anyone be able to tell me how to save a database and all its objects e.g. Procedures and views etc. onto a CD and then open it on another SQL Server? For SQL Server 7.0 and 2000.
Thanks
View 2 Replies
View Related
Apr 8, 2008
Hi all,
I have a replicated table with a column which is used to store sound files - it is of type varbinary(MAX).
What is the best way to store a file from the filesystem inside this column on the PDA side (i.e. inside SQL Server CE) without loading the whole file into the PDA's memory, i.e. using some sort of buffering?
On full SQL Server 2005 I make use of UPDATE.WRITE() to save buffers inside the column - is there an alternative to this on SQL Server CE? Can anyone provide sample code / point me to samples that deal with SQL Server CE & BLOBs.
Thanks for your help!
View 11 Replies
View Related
Oct 19, 2006
can some one help me. im using visual studio.net 2005. its a web application.i have a database with attribute name logo. so i want to upload an image and save it into the database and than display it into the image box to preview how the image looks like.can some one please help me as i am very new in using C# codes and visual studio.net 2005
View 5 Replies
View Related
Jan 2, 2007
hi
I have binary files inside my database. and user should have the opportunity to download them from database to his computer. I don't want to retrive and save the file into the server first and then let him to download. is it posible???
thank you in advance
regards
View 3 Replies
View Related
Dec 6, 2005
Hi,Using VB.net I have created a custom object (hope my terminology is correct here), it’s just a class that defines a few string, integer, and hash table variables. After creating an instance of this class and populating it with data I need to be able to store this instance of my object in a sql server data base table. How do I do this? I saw an article that used the image data type to achieve this (code was in java unfortunately) is this the correct approach. Could you please give me some code examples
Thanks
View 1 Replies
View Related