Upload Images And Text To Database

Mar 22, 2008

 I have a form that inserts text and also allows the user to upload 3 images.  I have the text part working, but can't figure out how to get the images uploaded.
 Here is the form.  I just inserted the 3 upload controls in the form and in the datasource to show what I am trying to do.  If anybody can help me I appreciate it. 

 1 <h3><br />Add Listing</h3><hr />
2 <div style="margin:auto;">
3 <table align="center" >
4 <tr>
5 <td align="right">
6 Address:</td>
7 <td>
8 <asp:TextBox ID="TbAddress" runat="server" MaxLength="62" Width="250px"></asp:TextBox> </td>
9 </tr>
10 <tr>
11 <td align="right">
12 City:</td>
13 <td align="left">
14 <asp:TextBox ID="TbCity" runat="server" MaxLength="62" Width="250px"></asp:TextBox></td>
15 </tr>
16 <tr>
17 <td align="right">
18 State:</td>
19 <td align="left">
20 <asp:DropDownList ID="DdState" runat="server">
21 </asp:DropDownList>
22 </td>
23 </tr>
24 <tr>
25 <td align="right">
26 Zip Code:</td>
27 <td align="left">
28 <asp:TextBox ID="TbZipCode" MaxLength="15" Width="75px" runat="server"></asp:TextBox>
29 </td>
30 </tr>
31
32 <tr>
33 <td align="right">
34 Listing Price:</td>
35 <td align="left">
36 <asp:TextBox ID="TbListingPrice" runat="server" MaxLength="30" Width="125px"></asp:TextBox></td>
37 </tr>
38 <tr>
39 <td align="right">
40 Taxes/Half:</td>
41 <td align="left">
42 <asp:TextBox ID="TbTaxes" runat="server" MaxLength="30" Width="125px"></asp:TextBox></td>
43 </tr>
44 <tr>
45 <td align="right">
46 Subdivision:</td>
47 <td align="left">
48 <asp:TextBox ID="TbSubdivision" runat="server" MaxLength="60" Width="225px"></asp:TextBox></td>
49 </tr>
50 <tr>
51 <td align="right">
52 County:</td>
53 <td align="left">
54 <asp:TextBox ID="TbCounty" runat="server" MaxLength="60" Width="225px"></asp:TextBox></td>
55 </tr>
56 <tr>
57 <td align="right">
58 School District:</td>
59 <td align="left">
60 <asp:TextBox ID="TbSchoolDistrict" runat="server" MaxLength="60" Width="225px"></asp:TextBox></td>
61 </tr>
62 <tr>
63 <td align="right">
64 Bedrooms:</td>
65 <td align="left">
66 <asp:DropDownList ID="DdBedrooms" runat="server">
67 </asp:DropDownList>
68 </td>
69 </tr>
70 <tr>
71 <td align="right">
72 Bathrooms:</td>
73 <td align="left">
74 <asp:DropDownList ID="DdBathrooms" runat="server">
75 </asp:DropDownList>
76 </td>
77 </tr>
78 <tr>
79 <td align="right">
80 Living Space:</td>
81 <td align="left">
82 <asp:TextBox ID="TbLivingSpace" runat="server" MaxLength="30" Width="125px"></asp:TextBox></td>
83 </tr>
84 <tr>
85 <td align="right">
86 Stories:</td>
87 <td align="left">
88 <asp:DropDownList ID="DdStories" runat="server">
89 </asp:DropDownList>
90 </td>
91 </tr>
92 <tr>
93 <td align="right">
94 Building Style:</td>
95 <td align="left">
96 <asp:TextBox ID="TbBuildingStyle" runat="server" MaxLength="60" Width="225px"></asp:TextBox></td>
97 </tr>
98 <tr>
99 <td align="right">
100 Year Built:</td>
101 <td align="left">
102 <asp:TextBox ID="TbYearBuilt" runat="server" MaxLength="30" Width="125px"></asp:TextBox></td>
103 </tr>
104 <tr>
105 <td align="right">
106 Bastment:</td>
107 <td align="left">
108 <asp:DropDownList ID="DdBasement" runat="server">
109 </asp:DropDownList>
110 </td>
111 </tr>
112 <tr>
113 <td align="right">
114 Heating:</td>
115 <td align="left">
116 <asp:DropDownList ID="DdHeating" runat="server">
117 </asp:DropDownList>
118 </td>
119 </tr>
120 <tr>
121 <td align="right">
122 Cooling:</td>
123 <td align="left">
124 <asp:DropDownList ID="DdCooling" runat="server">
125 </asp:DropDownList>
126 </td>
127 </tr>
128 <tr>
129 <td align="right">
130 Image 1:</td>
131 <td align="left">
132
133 <asp:FileUpload ID="FileUpload1" runat="server" />
134 </td>
135 </tr>
136 <tr>
137 <td align="right">
138 Image 2:</td>
139 <td align="left">
140 <asp:FileUpload ID="FileUpload2" runat="server" />
141 </td>
142 </tr>
143 <tr>
144 <td align="right">
145 Image 3:</td>
146 <td align="left">
147 <asp:FileUpload ID="FileUpload3" runat="server" />
148 </td>
149 </tr>
150 <tr>
151 <td>
152 &nbsp;</td>
153 <td>
154 &nbsp;</td>
155 </tr>
156 <tr>
157 <td align="right">
158 <asp:Button ID="Button1" runat="server" Text="Save" />
159 </td>
160 <td>
161 &nbsp;</td>
162 </tr>
163
164
165 </table>
166
167 </div>
168
169
170 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:treesConnectionString %>"
171 InsertCommand="INSERT INTO SueHorvath(Address, City, State, ZipCode, ListPrice, Taxes, Subdivision, County, SchoolDistrict, Bedrooms, Bathrooms, LivingSpace, Stories, BuildingStyle, YearBuilt, Basement, Heating, Cooling, Image1, Image2, Image3) VALUES (@Address, @City, @State, @ZipCode, @ListPrice, @Taxes, @Subdivision, @County, @SchoolDistrict, @Bedrooms, @Bathrooms, @LivingSpace, @Stories, @BuildingStyle, @YearBuilt, @Basement, @Heating, @Cooling, @Image1, @Image2, @Image3)" >
172 <InsertParameters>
173 <asp:ControlParameter Name="Address" Type="String"
174 ControlID="TbAddress" />
175 <asp:ControlParameter Name="City" Type="String"
176 ControlID="TbCity" />
177 <asp:ControlParameter Name="State" Type="String"
178 ControlID="DdState" />
179 <asp:ControlParameter Name="ZipCode" Type="String"
180 ControlID="TbZipCode" />
181 <asp:ControlParameter Name="ListPrice" Type="String"
182 ControlID="TbListingPrice" />
183 <asp:ControlParameter Name="Taxes" Type="String"
184 ControlID="TbTaxes" />
185 <asp:ControlParameter Name="Subdivision" Type="String"
186 ControlID="TbSubdivision" />
187 <asp:ControlParameter Name="County" Type="String"
188 ControlID="TbCounty" />
189 <asp:ControlParameter Name="SchoolDistrict" Type="String"
190 ControlID="TbSchoolDistrict" />
191 <asp:ControlParameter Name="Bedrooms" Type="String"
192 ControlID="DdBedrooms" />
193 <asp:ControlParameter Name="Bathrooms" Type="String"
194 ControlID="DdBedrooms" />
195 <asp:ControlParameter Name="LivingSpace" Type="String"
196 ControlID="TbLivingSpace" />
197 <asp:ControlParameter Name="Stories" Type="String"
198 ControlID="DdStories" />
199 <asp:ControlParameter Name="BuildingStyle" Type="String"
200 ControlID="TbBuildingStyle" />
201 <asp:ControlParameter Name="YearBuilt" Type="String"
202 ControlID="TbYearBuilt" />
203 <asp:ControlParameter Name="Basement" Type="String"
204 ControlID="DdBasement" />
205 <asp:ControlParameter Name="Heating" Type="String"
206 ControlID="DdHeating" />
207 <asp:ControlParameter Name="Cooling" Type="String"
208 ControlID="DdCooling" />
209
210 <asp:ControlParameter Name="FileUpload1" Type="String"
211 ControlID="FileUpload1" />
212 <asp:ControlParameter Name="FileUpload2" Type="String"
213 ControlID="FileUpload2" />
214 <asp:ControlParameter Name="FileUpload3" Type="String"
215 ControlID="FileUpload3" />
216
217
218 </InsertParameters>
219
220 </asp:SqlDataSource>

  And here is the code behind
 
 
 1
2 Partial Class mylistings
3 Inherits System.Web.UI.Page
4 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
5
6 SqlDataSource1.Insert()
7 TbAddress.Text = ""
8 TbCity.Text = ""
9 DdState.Text = ""
10 TbZipCode.Text = ""
11 TbListingPrice.Text = ""
12 TbTaxes.Text = ""
13 TbSubdivision.Text = ""
14 TbCounty.Text = ""
15 TbSchoolDistrict.Text = ""
16 DdBedrooms.Text = ""
17 DdBathrooms.Text = ""
18 TbLivingSpace.Text = ""
19 DdStories.Text = ""
20 TbBuildingStyle.Text = ""
21 TbYearBuilt.Text = ""
22 DdBasement.Text = ""
23 DdHeating.Text = ""
24 DdCooling.Text = ""
25
26
27
28
29 Response.Redirect(Request.Url.ToString(), False) ' will include the querystring
30 End Sub
31 End Class
32
  

View 7 Replies


ADVERTISEMENT

Need To Upload Images To Database - Help

May 30, 2008

Hia,

We have a simple table which we need to store logo's for a website. The table looks like this:

CLIENTLOGO (Tablename)
id (Bigint) (PK) - NOT NULL
StoredImage (Image) - NOT NULL
ImageSize (Integer) - NULL

Im not an expert on sql sorry!

I have two problems,
1. I need to upload some logo's (they are gif's if thats important)
2. I need to store the image size

I don't have a clue how to do 2 but ive tried the following for 1 but it doesnt seem to work

Insert into CLIENTLOGO (id, storedImageTablename)
Values (1, 'c:ClientLogo1.gif')

Can somebody help, im really confused about this one

View 4 Replies View Related

How To Upload And Retrieve Images From The Database

Mar 26, 2008

i am using sql server,asp.net and C# language.I am able to upload data into the database but couldnt retrieve it from the database.i am using the following code to upload image into the database.kindly help.
 
 SqlConnection connection = null;         try         {             FileUpload img = (FileUpload)imgUpload;             Byte[] imgByte = null;             if (img.HasFile && img.PostedFile != null)             {                 HttpPostedFile File = imgUpload.PostedFile;                 imgByte = new Byte[File.ContentLength];                 File.InputStream.Read(imgByte, 0, File.ContentLength);             }             string conn = connection establishing string;             connection = new SqlConnection(conn);             connection.Open();             string sql = "insert into imagetable values(@enm, @eimg) SELECT @@IDENTITY";             SqlCommand cmd = new SqlCommand(sql, connection);             cmd.Parameters.AddWithValue("@enm", txtEName.Text.Trim());             cmd.Parameters.AddWithValue("@eimg", imgByte);             int id = Convert.ToInt32(cmd.ExecuteScalar());             lblResult.Text = String.Format("Employee ID is {0}", id);         }         catch         {             lblResult.Text = "There was an error";         }        finally        {            connection.Close();        }

View 9 Replies View Related

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 To Upload Images To SQL2005 (using C#) And Retreive Them

Sep 13, 2007

Hi guys,    I'm creating a webSite and i'd like to save images to my db. I've been using fileUpload to get the image i want to store, but i can't get it right! After "mastering" the storage of my images , i'd like to be able to retrieve them. I allready have SPs created for both storage & retrieval of images!Can anyone help me please? Thanks,superJB

View 3 Replies View Related

Browsing For Files (Images) To Upload To Server

Jun 9, 2007

 How do i Browser for files in computer, and upload them to Server? then link the file's URL(on server) into a Database.What i am wanting to do: Upload pictures (For products) for use in product pages What i think i need: Browse for images on local computerUpload the file to ServerStore the Image URL(relative to server) in DB

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

Upload Text Files Thru DTS/SSIS

Jan 31, 2007

I have created a DTS package which imports text file into single sql server table with 8 columns (SourceData). The DTS package uses 'Test1.txt' file. Now i have around 200 text files (Test1,Test2,.....Test200). I need to import them one by one into 'SourceData' table. Could you pls. help me out in getting solved.

Thanks,

Hemal

View 4 Replies View Related

Some Problem In Data Flow While Upload A || Seperated Text File

Jul 25, 2006

I am facing one problem with sql 2005 SSIS while uploading a "||" seperated text file with Data Flow in SSIS.Below I am giving the sample data of the text file

data||data||data

data||data||data

When I uploaded it using sql 2000 DTS it was not giving and it was being uploaded into the table but when I tried with SQL 2005 it is giving the below problem.

"[Flat File Source [1]] Error: Data conversion failed. The data conversion for column "Column 2" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.". "



View 10 Replies View Related

Display Programatically Images,text In A Page

Sep 14, 2004

hi everyone.
i want to build a page that all datas,images will store in sql server.
i want to display images,text from database in a page with a template (images left of the page,text near the image and like....,programatically)
there will be very much data . about 500-1000 pages data.
is this possible with sql server?
can SQL server store big datas?
if it is possible can you give me an idea.

View 1 Replies View Related

[MSSQL] Blob-upload In Table With Full Text Index Goes Slow

Oct 31, 2005

i have a MSSQL 2000 database with about 30 tables in it. On one of those tables i've defined an full text index on an image field. In this table are around 500 records with binary files.

it functioned well for a time but now when i try to upload a file into the table this goes extremely slow (300 KB takes over 3 minutes).

i tried disabling "change tracking" but this didn't help a thing

adding blobs to other tables (without fulltext index on it) still goes fast.

what could be a reason that the uploading goes so slow??

View 3 Replies View Related

SQL Server 2008 :: Upload 1000 Text Files Into One Table - Skip Last Row?

Jul 19, 2015

Im trying to upload 1000 txt files into one table in SQL. I'm using the following query, to upload one txt file at a time:

bulk insert [dbo].AAA_2013_2015
from 'dataserverSQL Data FilesSQL_EMELIZFC x Bloque Detallada201308 Detalle FacturasFACT_BLOQ_AGO13 (4).txt'
with (firstrow = 2,
lastrow = ???,
fieldterminator = ';',
rowterminator = '0x0A')

I'm trying that the query skip the last row because gives me the following error:

Msg 4866, Level 16, State 1, Line 1
The bulk load failed. The column is too long in the data file for row 1, column 17. Verify that the field terminator and row terminator are specified correctly.
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

know a command to skip the last row, something like lastrow= all-1...or something like that.

I also executed using MAXERRORS command...like this:

bulk insert [dbo].AAA_2013_2015
from 'dataserverSQL Data FilesSQL_EMELIZFC x Bloque Detallada201308 Detalle FacturasFACT_BLOQ_AGO13 (15).txt'
with (firstrow = 2,
fieldterminator = ';',
MAXERRORS = max_errors,
rowterminator = '0x0A')

does not recognize MAXERRORS command, also tried to put a number of error instead of max_errors.

View 0 Replies View Related

Reporting Services :: How To Rotate Text 180 Degrees Without Using Images

Oct 13, 2011

I'm currently working on a report and have all the requirements taken care of save one. I need to flip my text 180 degrees. I have seen how to do this by making an image on the fly and then rotating the image, etc. And that is what we previously had in place.

Unfortunately the reports are getting so large (20 images on a page, 150 pages for the report) that the reports will not print in their entirety through Citrix and cuts off after about 120 pages.

I also tried using upside down fonts which won't work as they flip the letter on a X axis as opposed to rotating them along a pivot. Sadly we can't reduce the number of occurrences per page or decrease the page count. So those are not options. They were the first things I asked about.

View 6 Replies View Related

Why Is SSIS Upload From FoxPro Way Slower That A Upload Using DTS?

Oct 20, 2006

I am rewritting our DTS that upload tables in FoxPro to SQL Server using SSIS. I am finding the that SSIS is way slower. My uploads using DTS take just 7 minutes where doing the same thing in SSIS is taking 1 hour 15 minutes.

View 2 Replies View Related

Upload Database

Oct 22, 2007

I created a website a year ago. I remember I need to download something from Microsoft (some kind of sql admin thing), which allows me to convert my database in the Express Visual Web developer to sql file, then I can copy those sql commands into my web hosting company's sql admin window to upload the database online. I forgot what things I should download from Microsoft? Please help.

View 1 Replies View Related

About XML Upload To Database

Jun 7, 2007

HI

Can anyone tell me how to upload a xml file in a table.I have uploaed text,csv,xel file but never xml.

just want to know how to upload, and when,why should we use xml file for data

thanks

sandipan

View 1 Replies View Related

Upload SQL Database To Server

Sep 19, 2006

Okay, I am still really new at this so nobody laugh if this seems simple stupid.  I created a little web page and while working on the project created a new database by right clicking on my app and clicking "Add New item" then choosing SQL Database.  I added tables and everything was working just dandy on my machine.  I FTP'd the files up to my web server and am now getting an error.  SQL is installed on the server, but I have a couple of questions.1. Does SQL have to be installed on the server if you create one of these databases by doing the Add New Item button?2. After Uploading it to a server with SQL installed, the database shows in my App Data folder, but gives me an error.  What needs done to move this database to the server besides uploading it?Here is my error:An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)  

View 11 Replies View Related

How Do I Upload A MSDE Database

Sep 26, 2006

Downloaded and installed MSDE and just finished creating a
website using the Community Starter Kit.  I'm used to working with Access
Databases and this is my first experience with anything SQL.  Can someone
provide my with some guidance as to what I need to do to upload the MSDE
Database to a server.  Can I just upload the files like an Access Database
or is this more involved.  Thanks for you help.

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

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

Upload Database From Sql 7 To COBOL???

Oct 21, 1999

I developed a database in MS SQL server7. But the main database was developed in COBOL. Is there anyway I can upload my
database to mainfram? Thank you in advance.

View 1 Replies View Related

How To Insert Images In The Data Type (BLOB - Images)

May 23, 2003

I am having a problem with MMSQL BLOB with VB, Sorry to say I am new in Programming using VB 6 and MSSQL and I have never touch BLOB in my live.

I just wish anyone could give me any ideal, like, white pages, or manual on how do I insert BLOB data (Images) to MSSQL 2000 database using VB 6. I need to know exspecially the VB Code and the SQL Portion if you have a store procedure code for that it will be nice.
:confused:

View 3 Replies View Related

Images With A Data Value Of A URL, I.e. Web Images, Appear In The Designer But Not In The Actual Report.

Feb 9, 2007

The URL address is for example http://backup/pics/19980.jpg

On the report when I right click on an image the URL is http://localhost/reportserver

I do not understand what is going on. Please help.

Many thanks,

Nic

View 1 Replies View Related

SQL 2005 Express Database Upload(help!)

Feb 15, 2007

Hi, how are you! I'm a beginner of database. I have some really "novice" questions here. Currently I'm trying to upload my database to a share windows host server. I have problems uploading my database files. I'm using Visual Studio 2005 and SQL 2005 express version. I was told that in order to upload my database, I need to have.bak file of my database.
The problems are:
 1. under my visual studio server explorer, it seems I have two databases, one is ASPNETDB.MDF, another one is (mycomputername)sqlexpress.(databasename).dbo. I dont know from which one I can create the .bak file, and how?
2. I can not find where the phsyical location of my files (such as tables or stored procedures) from my (mycomputername)sqlexpress.(databasename).dbo database. Anyone can help? thank you!

View 3 Replies View Related

How To Upload A Videofile Into Database Using Asp.net2.0

Apr 25, 2007

Hi pals.........
I have a problem that uploading a video file into the database using asp.net and sql server as database
please any one help me itzzz urgent for me............
 

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

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

How To Upload MSDE Database To Server??

Jun 6, 2004

Hello everyone,

I've got a simple yet concerning problem. How do I get the MSDE database I've created off my PC and onto the web server? I've thought of doing a "BACKUP DATABASE dbname TO DISK = 'blah,blah'", then upload it and hope I have permissions to execute a DATABASE RESTORE... Any other methods?

View 1 Replies View Related

How Can I Upload The Files(any Kinda) Onto The Database???

Apr 15, 2005

Hi everyone,
I am developing an web-database application using ASP.NET, C# and sql server 2000 .
In the application i want to upload different scanned files (pdf,doc,excel,jpeg,ttf,etc) onto the database.. how can i carry out this task :-?
If any one got the solution.. then, please let me know...
thanks in advance
 

View 7 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 Database To Remote Server

May 12, 2006

I have a database on my local system and I use Sql Server 2005 express.  Now I need to upload the database in the hosting server. I have tried Management Studio Express.

View 1 Replies View Related

How To Upload / Publich A MSSQL Database

Aug 7, 2007

Hi all!

I am a newbie with SQL Server and need some advice. I have developed a small database with Microsoft SQL Server 2005 Express on my local computer. I am using it in conjunction with SQL Server Management Studio Express. Now I want to upload it to an online web host. What is the best way to upload? Do I use replication or some other means? Can I do so with Management Studio Express? My web host has an administration Console which does not seem to work with the database, and their support service is very slow. So I do not know what to do.

Any advice would be helpful.

Thank you

View 5 Replies View Related







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