Uploading Images Using An SQLDataSource Control

Nov 17, 2005

Hi,I would like to upload images using an SQLDataSource Control with a DetailsView, so that users can update/insert/delete records.Can someone tell me how I can do this in VB.NET ?It seems that I'm the only one on the world trying to do this already with ASP.NET VWD 2005.Thanks to all....Bart

View 1 Replies


ADVERTISEMENT

Uploading Images To SQL DB

Nov 17, 2005

Hi,I really appreciate any help from somebody that could help me on how I can upload images in a GridView or DetailsView using ASP.NET 2.0 - VB.NETI have looked on the internet, but could not find any example....Here are my pages :ASPX-Page :
<asp:SqlDataSource ID="SqlDataSource2"
runat="server" ConnectionString="<%$ ConnectionStrings:IMMOASPNETDBConnectionString %>"
DeleteCommand="DELETE FROM aspnet_BuyGroundImages WHERE (BuyGroundID = @Original_BuyGroundID)"
InsertCommand="AddImage" SelectCommand="SELECT BuyGroundID, BuyGroundDescription, Image1, Image2, Image3, Image4, Image5, OptionOn, Sold, Price FROM aspnet_BuyGroundImages" UpdateCommand="UPDATE aspnet_BuyGroundImages SET BuyGroundDescription = @BuyGroundDescription, Image1 = @Image1, Image2 = @Image2, Image3 = @Image3, Image4 = @Image4, Image5 = @Image5, OptionOn = @OptionOn, Sold = @Sold, Price = @Price WHERE (BuyGroundID = @original_BuyGroundID)" InsertCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="Original_BuyGroundID" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="BuyGroundDescription" />
<asp:Parameter Name="Image1" Type="Byte" />
<asp:Parameter Name="Image2" Type="Byte" />
<asp:Parameter Name="Image3" Type="Byte" />
<asp:Parameter Name="Image4" Type="Byte" />
<asp:Parameter Name="Image5" Type="Byte" />
<asp:Parameter Name="OptionOn" />
<asp:Parameter Name="Sold" />
<asp:Parameter Name="Price" />
<asp:Parameter Name="original_BuyGroundID" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="BuyGroundID" Type="Int32" />
<asp:Parameter Name="BuyGroundDescription" />
<asp:Parameter Name="Image1" />
<asp:Parameter Name="Image2" />
<asp:Parameter Name="Image3" />
<asp:Parameter Name="Image4" />
<asp:Parameter Name="Image5" />
<asp:Parameter Name="OptionOn" />
<asp:Parameter Name="Sold" />
<asp:Parameter Name="Price" />
<asp:Parameter Name="LastUpdated" Type="DateTime" />
</InsertParameters>

</asp:SqlDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
DataKeyNames="BuyGroundID" DataSourceID="SqlDataSource2" Height="50px" Width="125px" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal">
<Fields>
<asp:BoundField DataField="BuyGroundID" HeaderText="BuyGroundID" InsertVisible="False"
ReadOnly="True" SortExpression="BuyGroundID" />
<asp:BoundField DataField="BuyGroundDescription" HeaderText="BuyGroundDescription"
SortExpression="BuyGroundDescription" />
<asp:TemplateField HeaderText="Image1" SortExpression="Image1">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Image1") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
<!-- <input id="File1" type="file" language="javascript" runat="server" />
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Image1") %>'></asp:TextBox> -->
</EditItemTemplate>
<InsertItemTemplate>
<input id="File2" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Image1") %>'></asp:TextBox> -->
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image2" SortExpression="Image2">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Image2") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<input id="File3" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Image2") %>'></asp:TextBox> -->
</EditItemTemplate>
<InsertItemTemplate>
<input id="File4" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Image2") %>'></asp:TextBox> -->
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image3" SortExpression="Image3">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Image3") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<input id="File5" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Image3") %>'></asp:TextBox> -->
</EditItemTemplate>
<InsertItemTemplate>
<input id="File6" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Image3") %>'></asp:TextBox> -->
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image4" SortExpression="Image4">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Image4") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<input id="File7" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Image4") %>'></asp:TextBox> -->
</EditItemTemplate>
<InsertItemTemplate>
<input id="File8" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Image4") %>'></asp:TextBox> -->
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image5" SortExpression="Image5">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Image5") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<input id="File9" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Image5") %>'></asp:TextBox> -->
</EditItemTemplate>
<InsertItemTemplate>
<input id="File10" type="file" language="javascript" runat="server" />
<!-- <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Image5") %>'></asp:TextBox> -->
</InsertItemTemplate>
</asp:TemplateField>
<asp:CheckBoxField DataField="OptionOn" HeaderText="OptionOn" SortExpression="OptionOn" />
<asp:CheckBoxField DataField="Sold" HeaderText="Sold" SortExpression="Sold" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" ButtonType="Button" />
</Fields>
<FooterStyle BackColor="White" ForeColor="#333333" />
<EditRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" ForeColor="#333333" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
</asp:DetailsView>Code behind page:
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Partial Class gronden
Inherits System.Web.UI.Page
Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating
Try
'copy file data into record?
Dim upload As FileUpload = CType(Me.DetailsView1.FindControl("FileUpload1"), FileUpload)
If Not upload Is Nothing Then
If upload.PostedFile.FileName <> "" Then
'copy file to a byte array in memory
Dim data(upload.PostedFile.ContentLength) As Byte
upload.PostedFile.InputStream.Read(data, 0, upload.PostedFile.ContentLength)
'get filename part only
Dim filename As String
Dim tmp As Integer = upload.PostedFile.FileName.LastIndexOf("")
If tmp >= 0 Then
'strip directory part
filename = upload.PostedFile.FileName.Substring(tmp + 1, _
upload.PostedFile.FileName.Length - tmp - 1)
Else
filename = upload.PostedFile.FileName
End If
'save this to the fields
e.NewValues("Image1") = data
e.NewValues("FileName") = filename
e.NewValues("Contenttype") = upload.PostedFile.ContentType
End If
End If
Catch Ex As Exception
Response.Write(Ex.StackTrace)
End Try
End Sub
 
End Class

View 1 Replies View Related

Uploading Images

Apr 11, 2001

We are building an ASP application with SQL Server 2000 as a back end.

What is the best way to upload images to the server?

Thank you,
Anastasia.

View 1 Replies View Related

Uploading Images To Sql Server

Aug 22, 2003

Hope someone can help with this.

i am trying to upload images from an asp.net or vb.net front end to a sql server db.
I can upload the image fine if I first save the image to a file and then upload but my question is whether I can upload the image without first saving the image file. What i would like to do is to capture an image with a digital camera and without saving it first (an extra step for the user), upload it to a sql server db.

Is this even possible.

Thank you,

Biirir

View 2 Replies View Related

Uploading Multiple Images Into SQL

May 2, 2006

Hello,
I have 3000 images to upload in SQL. I have a page that does it in ASP.net 2.0 1 by 1 but i am looking for a faster way. The targeted table look like this
*ID (int)  ImgSize  (int)  ImgContentType  (nvarchar 50)  ImgFile  (image)
Thanks for the help.

View 1 Replies View Related

Uploading Images/writing Info To DB

Feb 6, 2007

In my continuing saga with writing my little real estate application, I've got the need to upload images to a folder within the website and then capture some image information in a db.  I know there are many ways to do this, and have read lots of them.  However most answers don't fit what I'd like to do, or they're too complicated for me.  Anyway, thought I'd write it from scratch.   So, I have 2 pieces of code, 1 that uploads the image to a folder, and another piece that captures information to a db.  The first part works great.  The image file successfully gets uploaded.  Problem lies in the db insert code.  It's not capturing and writing to the db.  Here's my code, and thanks in advance for your help!
Partial Class Default2
Inherits System.Web.UI.PageProtected Sub page_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load    If IsPostBack Then      Dim path As String = Server.MapPath("~/images/")      Dim fileOK As Boolean = False      If FileUpload1.HasFile Then           Dim fileExtension As String            fileExtension = System.IO.Path. _                GetExtension(FileUpload1.FileName).ToLower()            Dim allowedExtensions As String() = _                 {".jpg", ".jpeg", ".png", ".gif"}            For i As Integer = 0 To allowedExtensions.Length - 1                 If fileExtension = allowedExtensions(i) Then                 fileOK = True            End If       Next       If fileOK Then            Try                 FileUpload1.PostedFile.SaveAs(path & _                       FileUpload1.FileName)                 Label1.Text = "File uploaded!"            Catch ex As Exception                 Label1.Text = "File could not be uploaded."            End Try       Else            Label1.Text = "Cannot accept files of this type."        End If    End IfEnd IfEnd Sub
========================================================================= 
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'Connect to the database and insert a new record into Products
Dim picDataSource As New SqlDataSource()picDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ToString()picDataSource.InsertCommandType = SqlDataSourceCommandType.TextpicDataSource.InsertCommand = "INSERT INTO Images (url, title, imageTag, fileName, PictureID) VALUES (@url, @title, @imageTag, @fileName, @PictureID)"
picDataSource.InsertParameters.Add("url", "~/images/")picDataSource.InsertParameters.Add("title", imgTitleTxtbox.Text)picDataSource.InsertParameters.Add("imgTag", imgTagTxtBox.Text)picDataSource.InsertParameters.Add("fileName", imgFileNameTxtBox.Text)picDataSource.InsertParameters.Add("PictureID", 3)
Dim rowsAffected As Integer = 0
Try    rowsAffected = picDataSource.Insert()Catch ex As Exception    Label2.Text = "Label 2 File could not be uploaded."
Finally     picDataSource = Nothing
End Try
If rowsAffected <> 1 Then    Label3.Text = "Label 3 File could not be uploaded."
Else    Label3.Text = "File uploaded!"End If
End Sub
End Class
====================================================================
Here's the HTML for the upload page:
<h1>Upload Property Image(s)</h1>
<table border="0" cellpadding="10" cellspacing="0" style="width: 757px">
<tr><td style="width: 100px" align="right"><strong>Image Title</strong></td><td style="width: 100px"><asp:TextBox ID="imgTitleTxtbox" runat="server"></asp:TextBox></td></tr>
<tr><td style="width: 100px" align="right"><strong>Image File Name</strong></td><td style="width: 100px"><asp:TextBox ID="imgFileNameTxtBox" runat="server"></asp:TextBox></td></tr>
<tr><td style="width: 100px" align="right"><strong>Image Tag ID</strong></td><td style="width: 100px"><asp:TextBox ID="imgTagTxtBox" runat="server"></asp:TextBox></td></tr>
<tr><td style="width: 100px; height: 38px" align="right"><strong style="text-align: right">Add Image</strong></td><td style="width: 100px; height: 38px"><asp:FileUpload ID="FileUpload1" runat="server" /></td></tr>
<tr><td style="width: 100px; height: 38px"></td><td style="width: 100px; height: 38px"><asp:Button ID="Button1" runat="server" Text="Upload Image" /></td></tr>
</table>
<br />
<asp:Label ID="Label1" runat="server"></asp:Label><asp:Label ID="Label2" runat="server"></asp:Label><asp:Label ID="Label3" runat="server"></asp:Label>

View 6 Replies View Related

Uploading A File To A SQL Database Via A Typed Dataset And Using The FileUpload Control.

Oct 2, 2006

I am trying to upload a file in ASP.net 2.0 to a SQL database using the FileUpload control. I am doing this by way of a typed dataset.Here is my code.Dim rta As New ResponseTableAdapterDim rdt As ResponseDataTable = rta.GetResponseByID(1)Dim rr As ResponseRow = rdt(0)Dim fs As New FileStream(fu.PostedFile.FileName, FileMode.Open, FileAccess.Read)Dim br As New BinaryReader(fs)Dim image() As Byte = br.ReadBytes(fs.Length)br.Close()fs.Close()rr.UploadFile = imagerr.NameFile = fs.Namerta.Update(rdt)The code runs without an error but afterwards I find that nothing has been stored in the UploadFile cell in the database but the file name has been stored in the NameFile cell in the database. Any ideas?Your help is much appreciated. James 

View 1 Replies View Related

Not Able To Display Images Of PNG Type When Placed In ReportViewer Control During Runtime

Jan 27, 2006

Hi,



I have placed a Image Control in ReportViewer , and in design mode the image(.png) is displayed properly and when it is deployed , i am not able to see the image.

whereas there is no problem of images of gif or jpg or bmp or jpeg type. only problem is image of png type.

View 4 Replies View Related

How To Show Multiple Images And Links Using Report Viewer Control ?

Jun 21, 2007

Hello Everyone,



I have a report which runs in local mode and while designing the report I have placed a single image control inside the list box as I don't know before hand how many images are there :



What is the way to show all the images using the one image control inside the report viewer control. ? Can be 2 or 3 or 4.....



Thanks for all the help.



Harsimrat

View 1 Replies View Related

Sqldatasource Control

Oct 23, 2007

please explain selectparameters and conflict detection property within sqldatasource control
mohsen

View 1 Replies View Related

Sqldatasource Control

May 6, 2008

hi friends,
I created sqldatasource control. In select command i written the query like this  "select * form emp" and bounded in grid.How can I change the query for searching the details according the date wise when i click the search button.
 

View 14 Replies View Related

SqlDataSource Control

Jun 7, 2008

Hello experts
i have a SqlDataSource Control on my web form. Here is the source for the control
<asp:SqlDataSource ID="sqlSearchDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:DbefomsConnectionString %>"
SelectCommand="SELECT [icon], [file_name], [path] FROM [tblfile] WHERE ([file_name] = @file_name)">
<SelectParameters>
<asp:ControlParameter ControlID="txtSearch" DefaultValue="0" Name="file_name" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
This control displays icon, file_name, path in GridView Control
The problem is How can i store the above field values in an asp.net variable.
Thanks
Regards
Ali

View 1 Replies View Related

Using The Sqldatasource Control

Dec 7, 2005

Do you have to use the sqldatasource in conjuction with another control like gridview or dropdown list?
I'd like to check to see if a record exists in one table before inserting data into another.
 
thanks
 

View 1 Replies View Related

SqlDataSource Control

Jan 31, 2006

Hello.I'm new to ASP.NET and trying to write data to a Microsft SQL Server. I have created a SqlDataSource control, which is 'connected' to my SQL server.Now my question is how i can put data in the database throw the control, and read data from it. I've read the site, but it's still unclear for me..Greetings!

View 1 Replies View Related

SqlDataSource Control Timeout

Aug 8, 2006

How do you set a timeout for an SqlDataSource control?

View 1 Replies View Related

How To Control SqlDataSource If We Know Only DataSourceID ?

Jan 16, 2007

Anyone can help me ?

View 4 Replies View Related

SqlDataSource Control Error

Jan 19, 2007

Hello:
I am having a little issue with an error that is frustrating me. I have a SqlDataSource within an asp:label control and also have a two dropdownlists inside that asp:label control also. When I select from the first dropdownlist, it should enable the second dropdownlist with the populated data, but instead I receive.
The SqlDataSource control 'sqlGetMLSByCity' does not have a naming container.  Ensure that the control is added to the page before calling DataBind.
Any ideas why this would be? Here is the web from portion:
<asp:Label ID="recip_form_request" runat="server" Visible="false">    <ul>        <li>Step one: Select listing type.</li>        <li>Step two: Select the City that you are reciprocating to.</li>        <li>Step three: Complete the Recip Form.</li>    </ul>    <asp:DropDownList ID="recip_form_type" runat="server" AutoPostBack="true" Visible="False">        <asp:ListItem Value="0" Text="(Select Form)"></asp:ListItem>        <asp:ListItem Value="1" Text="Residential"></asp:ListItem>    </asp:DropDownList>    <br />    <asp:DropDownList ID="outside_assoc_cities" runat="server" AutoPostBack="True" Enabled="False" DataTextField="city" DataValueField="id" Visible="False"></asp:DropDownList><br />    <asp:Label ID="city_mls_desc" runat="server"></asp:Label><br />    <asp:Button ID="page1_btn" runat="server" Text="Next >>" Visible="False" />    <asp:SqlDataSource ID="sqlCities" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ AppSettings:connectionstring %>" SelectCommandType="Text" SelectCommand="SELECT id, city FROM  tCityMaster"></asp:SqlDataSource>    <asp:SqlDataSource ID="sqlGetMLSByCity" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ AppSettings:connectionstring %>">        <SelectParameters>            <asp:ControlParameter ControlID="outside_assoc_cities" Name="City" />        </SelectParameters>    </asp:SqlDataSource></asp:Label>
then the code behind:
Protected Sub outside_assoc_cities_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles outside_assoc_cities.SelectedIndexChanged        If outside_assoc_cities.SelectedIndex > -1 Then            Dim ItemId As Integer = Integer.Parse(outside_assoc_cities.SelectedValue)            Dim MLSID As String = Nothing
            Dim cmd As New SqlCommand            Dim con As New SqlConnection            cmd.Connection = con
            Dim sqlGetMLSByCity_sql As SqlDataSource = CType(Page.FindControl("sqlGetMLSByCity"), SqlDataSource)            'using connectionstring from SqlDataSource Control            con.ConnectionString = sqlGetMLSByCity_sql.ConnectionString            'con.ConnectionString = sqlGetMLSByCity.ConnectionString
            cmd.CommandType = CommandType.Text            cmd.CommandText = "SELECT mls_id FROM pwaordev..tCityMaster WITH(NOLOCK) WHERE ID=@ID"
            cmd.Parameters.Add("@ID", SqlDbType.Int, 4).Value = ItemId
            Try                con.Open()                MLSID = cmd.ExecuteScalar                con.Dispose()                cmd.Dispose()            Catch ex As Exception                con.Dispose()                cmd.Dispose()                Response.Write(ex.ToString())            End Try
            'Further logic to display button depending on MLS            If Not String.IsNullOrEmpty(MLSID) Then                If MLSID = "B" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Greater South Bay MLS."                    page1_btn.Visible = True                ElseIf MLSID = "A" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Big Bear BOR, MLS, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "C" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Combined L.A./Westside MLS."                    page1_btn.Visible = True                ElseIf MLSID = "F" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Crisnet MLS, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "Y" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is DCAoR - Yucca Valley Area, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "D" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Desert Area MLS."                    page1_btn.Visible = True                ElseIf MLSID = "L" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is i-Tech Glendale/Pasadena."                    page1_btn.Visible = True                ElseIf MLSID = "M" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is MRM - Multi-Regional MLS."                    page1_btn.Visible = True                ElseIf MLSID = "R" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is RIM - Rim of the World MLS, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "G" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is SDI - San Diego, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                ElseIf MLSID = "S" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is SOCAL MLS - Southern California MLS."                    page1_btn.Visible = True                ElseIf MLSID = "T" Then                    city_mls_desc.Text = "The MLS system that covers " & outside_assoc_cities.SelectedItem.Text & " is Outside Area, which is not covered by Pacific West Association of REALTOR&reg, please contact us for more information."                    page1_btn.Visible = False                End If                'test.Text = MLSID                'If test.Text = "L" Then                'mls_text.Text = "i-Tech"                'End If            End If        End If    End Sub
Any help would be great, thank you!

View 1 Replies View Related

How To Control The Loading Of SqlDataSource?

Sep 20, 2007

I have an SqlDatSource that I have fully setup at design time, but I don't want it to open and load as soon as the page loads, instead I want to open it based on a condition.
How do you do that with a DataSource?
I know that I can simply remove the Select query, and then set it at run time, but I'm looking for something better, that allows me to have the Select query set at design time, in part because I have a lot of parameters.

View 3 Replies View Related

SqlDataSource Control Synchronization

Sep 29, 2007

Hello:
I have two SqlDataSource controls on two different pages: one is updating a table and the other is reading from the same table.
Now is it possible that the reader SqlDataSource control can be refreshed immediately (to reflect updates) when the other control updates the table?

View 1 Replies View Related

UpdateCommand In Sqldatasource Control

Oct 15, 2007

Hello all,
I am trying to update the record which involed the modification of key in Datakeynames, but when i click the update button from gridview, it doesn't allow to change the value of modified column.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet"                 ConnectionString="<%$ ConnectionStrings:WebsiteDataConnection %>" OldValuesParameterFormatString="old_{0}"                SelectCommand="SELECT * FROM [ServiceAgents]"                InsertCommand="INSERT INTO ServiceAgents VALUES(@Ser_STATE, @Ser_CITY, @Ser_AGENT, @Ser_PHONE, @Ser_EQUIPMENT)"                UpdateCommand="UPDATE ServiceAgents SET AGENT=@AGENT, PHONE=@PHONE WHERE (STATE=@STATE and CITY=@CITY and AGENT=@old_AGENT and EQUIPMENT=@EQUIPMENT)"                DeleteCommand="DELETE FROM ServiceAgents WHERE (STATE=@STATE and CITY=@CITY and AGENT=@AGENT and EQUIPMENT=@EQUIPMENT)" >                                <UpdateParameters>                    <asp:Parameter Type="String" Name="AGENT" />                    <asp:Parameter Type="String" Name="PHONE" />                                         <asp:Parameter Name="old_AGENT" />                    <asp:Parameter Type="String" Name="STATE" />                    <asp:Parameter Type="String" Name="CITY" />                    <asp:Parameter Type="String" Name="EQUIPMENT" />                </UpdateParameters>                                <InsertParameters>                    <asp:ControlParameter Name="Ser_STATE" ControlID="TextBox_state"/>                    <asp:ControlParameter Name="Ser_CITY" ControlID="TextBox_city"/>                    <asp:ControlParameter Name="Ser_AGENT" ControlID="TextBox_agent"/>                    <asp:ControlParameter Name="Ser_PHONE" ControlID="TextBox_phone"/>                    <asp:ControlParameter Name="Ser_EQUIPMENT" ControlID="TextBox_equip" />                   </InsertParameters>                                <DeleteParameters>                   <asp:Parameter Type="String" Name="STATE" />                    <asp:Parameter Type="String" Name="CITY" />                    <asp:Parameter Type="String" Name="AGENT" />                    <asp:Parameter Type="String" Name="EQUIPMENT" />                </DeleteParameters>                            </asp:SqlDataSource>
Does anyone got any ideas about it? Where is wrong in the control?

View 3 Replies View Related

FilterExpression And The SQLDataSource Control

Feb 16, 2008

I have a SQLDatasource control on a web page. It is the datasource for a gridview control.I want the gridview to show all jones if the FirstName textbox is left blank or empty. Right now I have to put a % in the FirstName textbox to get what I want. If I make the FirstNameTextBox empty or remove the % from the FirstNameTextbox it returns all the names in the database no matter what the last name is.How do I get it to work without having to use the % in the FirstName Textbox? THANKS!FilterExpression="LastName LIKE '%{0}%' and FirstName LIKE '%{1}%'"><FilterParameters>            <asp:ControlParameter ControlID="LastNameTextBox" Name="LastName" PropertyName="Text" DefaultValue="" />            <asp:ControlParameter ControlID="FirstNameTextBox" Name="FirstName" PropertyName="Text" DefaultValue="" /></FilterParameters>
Last Name: Jones___________First Name: %_____________FILTERBUTTON
GridviewLast Name      First NameBob                JonesBill                 Jones
 

View 6 Replies View Related

SqlDataSource And Wizard Control

Apr 8, 2008

I have not found anything useful on the Wizard control.  Anything I can find gets to the last step and then just takes the info you supplied and applies them to a bunch of Label.Text's - none that do work. 
So I am building a Wizard control for an HR system that will insert the information into SQL through a SqlDataSource.  The problem is, only the controls that are present in whichever step is currently selected in VWD will appear in the Command and Parameter Editor.
I tried to work around it by selecting the first step, then applying the controls in step 1 within the Parameter Editor, but when I go back to do step 2, it erases everything I just did for step 1.
How do I implement the Wizard with a SqlDataSource?

View 8 Replies View Related

Confused Need Help With SQLDataSource Control

Jun 2, 2008

I have a gridview that is tied to a SQLDataSource control. As the gridview is filled some of the ASPX code calls some code in the code behind page. Where I am having trouble is that in one of these calls I need to some how pass the id filed ("LISTID")of the table for the SQL statement in the code behind page and I'm not sure how to do it.
The code behind function is always using the same id and I do not know how to change it. Below is all the code.
 
Here is the calling code in the ASPX page.
"DeleteBtn" Visible='<%# IsDeleteBtnVisible %>' runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" ForeColor="#003399"> Here is the entire ASPX code.     class="header">            class="title">My Lists         "Span1">            Current List Filter:             "DropDownList2" cssclass="filterdropdown" AutoPostBack="true" runat="server">                "Active" Value="False">                "Done" Value="true">                                    --------------------------------------------------------------------------------"separator2"/>                        "list2">        "ScriptManager1"  EnablePartialRendering="true"  runat="server">          "Up2" UpdateMode="Conditional" runat="server">                                                                  "GridView1" runat="server" AutoGenerateColumns="False"                         DataKeyNames="LISTID" DataSourceID="SqlDataSource1"                        AllowPaging="True" AllowSorting="True" EnableViewState="False" GridLines="None"                         AlternatingRowStyle-BackColor="#FFFFCC" AlternatingRowStyle-Font-Size="Small"                         ForeColor="#FFFFCC" Font-Size="Small" AlternatingRowStyle-ForeColor="Black"                         Width="100%" HeaderStyle-ForeColor="White">                                                     "False">                                                            "LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update" ForeColor="#003399">                                "LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" ForeColor="#003399">                                                                                        "LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" ForeColor="#003399">                                "DeleteBtn" Visible='<%# IsDeleteBtnVisible %>' runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" ForeColor="#003399">                                                        "buttons">                            "commands">                                                                        "ITEM_DETAILS"  HeaderText="Details"  SortExpression="ITEM_DETAILS" ControlStyle-ForeColor="#003399">                            "name_edit">                            "name">                            "name">                                                                        "Pri" itemStyle-HorizontalAlign="Center" SortExpression="Priority" ControlStyle-ForeColor="#003399">                                                            "DropDownList1" Width="75" SelectedValue='<%# Bind("Priority") %>' runat="server">                                    "High" Value="3">                                    "Medium" Value="2">                                    "Low" Value="1">                                                                                                                                                        "pri" Text='<%# FormatPriority(Eval("Priority")) %>' runat="server">                                                        "priority">                            "#003399">                            "priority">                                                                        "DUEDATE" itemStyle-HorizontalAlign="Center"                              HeaderText="Due Date" DataFormatString="{0:MM/dd/yyyy}"                            SortExpression="DUEDATE" >
                            "Center">                        
                        "COMPLETEDON" itemStyle-HorizontalAlign="Center"                              HeaderText="Completed On" DataFormatString="{0:MM/dd/yyyy}"                            SortExpression="COMPLETEDON" >
                            "Center">                        
                        "Done" itemStyle-HorizontalAlign="Center" SortExpression="IsComplete">                                                            "CheckBox1" runat="server" Checked='<%# Bind("IsComplete") %>'>                                                        "iscomplete">                            "iscomplete">                                                            "Done" Text='<%# FormatDone(Eval("IsComplete")) %>' runat="server">                                                                                           
                                                                                                "Button2" runat="server" CommandName="Something" DataTextField="LISTID" DataTextFormatString="{0} active items" text='<%# Eval("LISTID") %>'>                                                                                                                                                                                                  "Empty">No lists                                                                        "White">                        "#FFFFCC" Font-Size="Small" ForeColor="Black">                                                                                                                         "Div1">               "Up3" UpdateMode="Conditional"  runat="server">                                            Add New List: "AddItem2" cssclass="newitem"                     runat="server">                "Button1" runat="server" OnClick="AddListBtn_Click" Text="Add">                                "txtdate" runat="server">                                                        "Button1" EventName="Click">                                                                        "SqlDataSource1" runat="server"         ConnectionString="&lt;%$ ConnectionStrings:FastTrackConnectionString %>"         SelectCommand="SELECT * FROM [TODO]">     Here is the code behind page code. Protected Function IsDeleteBtnVisible() As Boolean        '        Return IIf(itemCount = 0, True, False)
        'This is for my gridview        Dim strConn2 As SqlConnection = New SqlConnection        Dim cmd2 As SqlCommand = New SqlCommand        Dim rs2 As SqlDataReader        Dim test1 As String        Dim test2 As String
        strConn2.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("FastTrackConnectionString2").ToString()        strConn2.Open()
        cmd2.Connection = strConn2        cmd2.CommandText = "SELECT LISTID, (SELECT COUNT(0) AS ItemCount FROM TODO_SUB_ITEMS WHERE(LISTID = TODO.LISTID) AND (ISCOMPLETE ='False')) AS ItemCount FROM TODO WHERE (ISCOMPLETE ='False')"
        rs2 = cmd2.ExecuteReader()
        rs2.Read()
        Dim testlistid As Integer = rs2(0)        Dim intholder As Integer = rs2(1)
        strConn2.Close()        cmd2 = Nothing        strConn2 = Nothing
        Return IIf(intholder = 0, True, False)
    End Function

View 7 Replies View Related

Another SQLDataSource Control Question

Jun 4, 2008

I have a gridview that is filled from a SQLDataSource control when the page loads.
I need to do some updates and delets on this data and I wanted to know can you add more than one SQL statement to a SQLDataSource control or do I have to have a seprate control for each operation?
The SQL currently is just the standard SELECT *, I cannnot see a way to add statments.
Thanks,
Ty

View 3 Replies View Related

Question Regarding The SqlDataSource Control

Jun 11, 2008

There is something I don't understand or I am just missing something here.
Why is it that I can place an SqlDataSource1.Insert() or update, or delete, but not an SqlDataSource.Select() inside a button click event "for an example" without getting an Compilation Error?
Thanks,
xyz789

View 2 Replies View Related

SqlDataSource Control Does Not Appear In Designer

Feb 1, 2006

I have dragged 3 SqlDataSource Controls to the WebDesigner and none are appearing graphically in the Designer View, but they are in the Source View.  How can I get the control to appear in the designer.
 
Thanks,
Mark

View 5 Replies View Related

Configuring A SQLDatasource Control

Feb 26, 2006

When I configure a SQLDataSource control I want the following where clause...
WHERE     (RegionID = @RegionID AND DistrictID IS NULL AND CampusID IS NULL) OR (DistrictID = @DistrictID AND CampusID IS NULL ) OR(CampusID = @CampusID AND UserRole = 'CampusAdmin') OR (CampusID = @CampusID)but it gets reformated as....
WHERE     (RegionID = 'Region10') AND (DistrictID IS NULL) AND (CampusID IS NULL) OR                      (DistrictID = 2) AND (CampusID IS NULL) OR (CampusID = '999999103') AND (UserRole = 'CampusAdmin') OR                       (CampusID = '999999103')I don't think these are functionaly equivelant, are they?If not how do I stop the 'wizard' from reformatting the SQL where clause?Thanks

View 3 Replies View Related

Sqldatasource Control Inserting Problems

Oct 6, 2006

I set up a Sqldatasource control in 2.0 and I can retrieve data through a SQL Server connection from a stored procedure.  My problem is when I set up the insert command object through the wizard for the Sqldatasource control with another stored procedure for inserting data and call the insert method of my Sqldatasource object i get nothing not even an error it just goes through the code like nothing was wrong and I don't get anything inserted.  I don't know if this could be a problem but one of the parameters in the stored procedure is declared like this: @return tinyint output. I don't know how the Sqldatasource accounts for return parameters.  Here is the code for the insert for the Sqldatasource object.<asp:SqlDataSource ID="sdsMain" runat="server" ConnectionString="<%$ ConnectionStrings:SN_CUSTOMERConnectionString %>"InsertCommand="uspSNOrder_Promo_Live" InsertCommandType="StoredProcedure" SelectCommand="uspOPFillPromo"SelectCommandType="StoredProcedure"><InsertParameters><asp:ControlParameter ControlID="ddlPromo" Name="promoid" PropertyName="SelectedValue"Type="Int32" /><asp:Parameter DefaultValue="1" Name="datasourceid" Type="Int32" /><asp:Parameter DefaultValue="0" Name="datasourcekey" Type="String" /><asp:Parameter DefaultValue="9" Name="salesroomid" Type="Int32" /><asp:Parameter DefaultValue="9999" Name="userid" Type="Int32" /><asp:ControlParameter ControlID="txtFName" DefaultValue="" Name="firstname" PropertyName="Text"Type="String" /><asp:ControlParameter ControlID="txtLName" Name="lastname" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtAddress" Name="address" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtCity" Name="city" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtState" Name="state" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtZip" Name="zip" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtPhone" Name="phone" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="txtEmail" Name="email" PropertyName="Text" Type="String" /><asp:ControlParameter ControlID="ddlStatus" Name="status" PropertyName="SelectedValue"Type="Int32" /><asp:Parameter DefaultValue="0" Direction="InputOutput" Name="return" Type="Byte" /></InsertParameters></asp:SqlDataSource>Thanks in advance

View 1 Replies View Related

Sqldatasource Server Control Problem

Apr 2, 2007

Dear all,I am couping a dropdownlist and a sqldatasource control to display a column from a database of SQL/Server on browser. However, when I tried to configure the sqldatasource to let it get data from SQL/Server, it always report an error. It normally happens at the first step of creating new connection. After I specified the correct sql/server instance name, using SQL server authentication, and select a database name. Even the connection test can sucessfully passed. However, when I click the "OK" button, an error message saying "object reference not set to an instance of an object" popped out and I could not add new connections. The strange thing is that after I reintall the visual studio 2005 service pack 1. It will function properly for a while. After sometime, it will fail again.  Anybody has suggestions? Thanks a lot! 

View 1 Replies View Related

How To Retrieve Data From A SQLDataSource Control

Jun 10, 2007

I have made a SQLDataSource control with the select command:
SELECT COUNT(*) AS 'Antall' FROM Utgivelse WHERE (medieID = @medieID)
I want to use the "Antall" result programmatically in C# code. I try the following statement:        IDataReader MyReader;
 
       MyReader = CType(SqlDataSource2.Select(DataSourceSelectArguments.Empty),IDataReader);
but it doesnot work. Can somebody help me how to get the data from th control ?
Tom

View 2 Replies View Related

Stored Prcedures And SQLDataSource Control

May 28, 2008

Is it possible to place a stored procedure in a SQLDataSource control that needs a variable input then run it later?
DETAILS
I have 2 pages with gridview controls that are linked to a SQLDataSource controls.
What I would like to do is when the user clicks on a link in the gridview of the first page I want to take the value of the link clicked and pass it to the second page where it is placed into a variable that would be used in a WHERE clause to fill the second pages gridview.
I have no problem getting the value into a variable in the page load event of the second page. What I would be nice is since the gridview is already tied to a SQLDataSource control with the columns specified is if I could some how pass the variable to a stored procedure in the control so I don't have to manually pull and fill the data.
Any thoughts would be apperciated.
Thanks,
Ty 
 
 

View 3 Replies View Related

Timestamp Concurrency Control With SQLDataSource

Nov 10, 2005

I am trying to use a 'timestamp' type column with SQLDataSource for concurrency control with SQL Server.  I'm getting the following error:
Operand type clash: timestamp is incompatible with sql_variant
It appears that the problem is that the value for the Type property of the Parameter (which was generated by the SqlDataSource wizard) is Object which maps to 'sql_variant' rather than to 'timestamp'.
I know that the older way of doing things with SqlDataAdapter, SqlCommand, SqlParameter can handle timestamps because SqlParameter has a SqlDbType property that can have a value of SqlDbType.Timestamp, but I don't see how to do this with the newer SqlDataSource, Parameter classes because the Parameter.Type property (of type TypeCode) doesn't have a Timestamp value.
Has anyone been able to use a 'timestamp' type field with SqlDataSource?
Here's my sample code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MyTestPage.aspx.cs" Inherits="MyTestPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title>Untitled Page</title></head><body><form id="form1" runat="server"><div><asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"EmptyDataText="There are no data records to display." DataKeyNames="MyID"><Columns><asp:CommandField ShowEditButton="True" /><asp:BoundField DataField="MyID" HeaderText="MyID" InsertVisible="False" ReadOnly="True"SortExpression="MyID" /><asp:BoundField DataField="MyDesc" HeaderText="MyDesc" SortExpression="MyDesc" /></Columns></asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"ConnectionString="<%$ ConnectionStrings:CtrlConnectionString1 %>" DeleteCommand="DELETE FROM [MyTest] WHERE [MyID] = @original_MyID AND [MyDesc] = @original_MyDesc AND [timestamp] = @original_timestamp"InsertCommand="INSERT INTO [MyTest] ([MyDesc], [timestamp]) VALUES (@MyDesc, @timestamp)" OldValuesParameterFormatString="original_{0}"ProviderName="<%$ ConnectionStrings:CtrlConnectionString1.ProviderName %>" SelectCommand="SELECT [MyID], [MyDesc], [timestamp] FROM [MyTest]"UpdateCommand="UPDATE [MyTest] SET [MyDesc] = @MyDesc WHERE [MyID] = @original_MyID AND [MyDesc] = @original_MyDesc AND [timestamp] = @original_timestamp"><DeleteParameters><asp:Parameter Name="original_MyID" Type="Int32" /><asp:Parameter Name="original_MyDesc" Type="String" /><asp:Parameter Name="original_timestamp" Type="Object" /></DeleteParameters><UpdateParameters><asp:Parameter Name="MyDesc" Type="String" /><asp:Parameter Name="timestamp" Type="Object" /><asp:Parameter Name="original_MyID" Type="Int32" /><asp:Parameter Name="original_MyDesc" Type="String" /><asp:Parameter Name="original_timestamp" Type="Object" /></UpdateParameters><InsertParameters><asp:Parameter Name="MyDesc" Type="String" /><asp:Parameter Name="timestamp" Type="Object" /></InsertParameters></asp:SqlDataSource></div></form></body></html>

View 3 Replies View Related

Bind The Asp:SqlDataSource To A Label Control

Nov 12, 2005

how can i display the result of an  asp:SqlDataSource into a lable control.the sqldatasource returns the count for some thing ie "select count(*) as total from tbl"please help

View 1 Replies View Related







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