SqlDataSource+ControlParameter+Textbox

Jan 15, 2008

Hi!

I have a page (a search page) with sqldatasource, gridview and set of textboxes. The sqldatasource is using stored procedure with parameters. Using the visual wizard i'm associating the parameters with apropriate textboxes controls. It all works, like a charm.

The problem arises when I input some dangerous code in any textbox , like ' or % .

I'm having exception about unenclosed strings, generally info about the possibility of sql injection.

I thought that using ControlParameters, any Parameter in fact is sqlinjection safe, but apparently it isn't.

Does anyone know the right way of achieving my goal? It's very urgent.

View 7 Replies


ADVERTISEMENT

How To Add ControlParameter To SqlDataSource At Runtime?

Dec 8, 2006

Hi!
My question is exactly the subject.
My Web Form has only a GridView and a DetailsView, there is no SqlDataSource at project time, i create the SqlDataSource at runtime using code like this in the Page_Load event: (I NEED IT TO BE CREATED DYNAMICALLY)1 Dim SQLDS As SqlDataSource = New SqlDataSource()
2
3 SQLDS.ID = "CustomerDataSource"
4 SQLDS.ConnectionString = ConfigurationManager.ConnectionStrings("connectionstring").ConnectionString
5 SQLDS.SelectCommand = "select customerid,companyname,contactname,country from customers"
6 SQLDS.InsertCommand = "insert into customers(customerid,companyname,contactname,country) values(@customerid,@companyname,@contactname,@country)"
7 SQLDS.UpdateCommand = "update customers set companyname=@companyname,contactname=@contactname,country=@country where customerid=@customerid"
8 SQLDS.DeleteCommand = "delete from customers where customerid=@customerid"
9
10 SQLDS.UpdateParameters.Add(New Parameter("companyname"))
11 SQLDS.UpdateParameters.Add(New Parameter("contactname"))
12 SQLDS.UpdateParameters.Add(New Parameter("country"))
13 SQLDS.UpdateParameters.Add(New Parameter("customerid"))
14
15 Page.Controls.Add(SQLDS)
16
17 If Not Page.IsPostBack Then
18 GridView1.DataKeyNames = New String() {"customerid"}
19 GridView1.DataSourceID = SQLDS.ID
20
21 ' ... and so on
The DetailsView1 uses the same SqlDataSource to show data, but i could not find a way to synchronize the DetailsView1 with the GridView1 when a record is selected in the GridView1.How can I synchronize the DetailsView?I played with the ControlParameter but i can't find either how to add a ControlParameter in code, is there a way? Every place talking about ControlParameter shows something like this: 1 <asp:SqlDataSource ID="SqlDataSource1" runat="server"
2 ConnectionString="<%$ ConnectionStrings:Pubs %>"
3 SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors] WHERE [state] = @state">
4 <SelectParameters>
5 <asp:ControlParameter Name="state" ControlID="DropDownList1" PropertyName="SelectedValue" />
6 </SelectParameters>
7 </asp:SqlDataSource>
8
 Ok. OK. But my SqlDataSource is created dynamically. Any ideas on how to solve this problem?Thanks!

View 3 Replies View Related

Passing Parameters To SQL Stored Procedure With SQLDataSource And ControlParameter

Mar 28, 2007

Hello,
I'm having trouble executing a Stored Procedure when I leave the input field empty on a 'search' criteria field. I presume the error is Null/Empty related.
The Stored Procedure works correctly when running in isolation. (with the parameter set to either empty or populated)
When the application is run and the input text field has one or more characters in it then the Stored Procedure works as expected as well.
 
Code:
.
.
<td style="width: 3px">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
.

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="LogId" DataSourceID="SqlDataSource1"
Width="533px">
<Columns>
<asp:BoundField DataField="LogId" HeaderText="Log Id" InsertVisible="False" ReadOnly="True"
SortExpression="LogId" />
<asp:BoundField DataField="SubmittedBy" HeaderText="Submitted By" SortExpression="SubmittedBy" />
<asp:BoundField DataField="Subject" HeaderText="Subject" SortExpression="Subject" />
<asp:TemplateField>
<ItemTemplate>
<span>
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink></span>
</ItemTemplate>
</asp:TemplateField>
 
</Columns>
<HeaderStyle BackColor="#608FC8" />
<AlternatingRowStyle BackColor="#FFFFC0" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SmallCompanyCS %>"
SelectCommand="spViewLog" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="txtName" ConvertEmptyStringToNull="true" Name="name" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
Stored Procedure:
ALTER PROCEDURE dbo.spViewLog (@name varchar(50) )
 
AS
SELECT * FROM log_Hdr WHERE (log_hdr.submittedby LIKE '%' + @name + '%')
RETURN
 
I have tried the 'convertemptystringtonull' parameter but this didn't seem to work.
 Any guidance would be much appreciated.
Thank you
Lee
 
 

View 2 Replies View Related

How Do I Get The SqlDataSource To Look At The Textbox

Mar 6, 2006

I am working with a Detailsview.  I am displaying information from a number of different tables, and so when I configure the datasource I have to specify a custom sql statement.  I can get it to display the right columns, but I cannot seem to be able to use a where statement.
I am wanting to display the info in the Detailsview based on what is entered into a textbox, but I get an error when I try to add in the where statement.  Can someone tell me what I am missing here?
Thanks

View 3 Replies View Related

Textbox Search Using Sqldatasource

Jul 3, 2006

I enter a id in the textbox and based on that it give me a list of all entries in gridview that use that id.This works.But if I leave it blank it gives me nothing.  I want to make it so if I leave it blank it give me all the id's.Do I have to modify the sqldatasource on pageload?

View 1 Replies View Related

Binding Textbox With SqlDataSource

Mar 9, 2007

Hi,    I wants to bind textbox with sqldatasource in c#.net so I am using following code and has following error... Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.Source Error:



Line 22: Line 23: System.Data.DataView dv = (DataView) SqlDataSource1.Select(System.Web.UI.DataSourceSelectArguments.Empty);Line 24: TextBox1.Text = dv[0]["Proid"].ToString();Line 25: Line 26: }Please, anybody knows solution tell me 

View 1 Replies View Related

Display Return Value From Sqldatasource In Textbox

Feb 26, 2007

Hi,

View 1 Replies View Related

Binding A SqlDataSource To A TextBox Or Label

Feb 28, 2007

I have a SQL database with 1 column in it.. it is a do not call registry for my office.  I want to make a web application so our leads can go on the web and request to be put on the do not call list.  problem is, if their number already exists, it gets a violation of primary key... Normal handling for this would be to do a select query based on user input, and if it exists in the database, tell them that, else do the insert query... Problem is, i cant seem to figure out how to bind the result of the select query to a textbox or label so i can compare the results to do that logic.  Any ideas?  This is in asp .net 2.0.  Thanks! -Dan       

View 5 Replies View Related

Move Data From SqlDataSource To A TextBox

Apr 9, 2007

I have a DataReader on a web page: <asp:SqlDataSource ID="ChangeInfoRecord" runat="server" ConnectionString..........
I want to display the value of one of the returned field in a text box.  What is the correct syntax?  I tried
RolledFromDisplay.Text = ChangeInfoRecord("RolledFrom")
but that isn't it.

View 1 Replies View Related

How To Retrieve Data From Sqldatasource To Textbox

Sep 4, 2007

 my problem is i can't retrieve data from my sqldatasource to be displayed in textbox... i try to do it in vb codes. somebody help me here?

View 4 Replies View Related

How To Fill Textbox With Data Using Sqldatasource?

Jan 30, 2008

I want to fill text box using sqldatasource ...
how can i do that ??
thanx in advace ..

View 10 Replies View Related

Setting SqlDatasource Parameters From TextBox

Feb 17, 2008

I have a sqlDatasource with 3 parameters based on the input of 3 text boxes on the page. The datasource returns sales details for a company based on a from and to date. I am attempting to set the value of the 3 parameters in the Selecting event of the datasource control but I'm not getting any data back. If I set the values literally then I get data back. Also when I step through the code I can see the 3 parameters getting their values from the textboxes and the drop down list as they should. This is driving me insane as I'm new to .net and just can't see what is stopping me retrieving the data when using the form fields to set the datasources parameters. Below is the aspx and the code behind for the page. Thanks in advance for any help. aspx..... <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="LabelSales.aspx.cs" Inherits="LabelSales" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">        <asp:SqlDataSource ID="SqlDataSourceSales" runat="server" EnableCaching="false"        ConnectionString="<%$ ConnectionStrings:streetwisedigitalConnectionString %>"        SelectCommand="DL_GET_SALES_BY_LABEL" SelectCommandType="StoredProcedure" OnSelecting="SqlDataSourceSales_Selecting" >        <SelectParameters>            <asp:Parameter Name="fromDate" />            <asp:Parameter Name="toDate" />            <asp:Parameter Name="label" />        </SelectParameters>    </asp:SqlDataSource>        <asp:SqlDataSource ID="SqlDataSourceLabels" runat="server"         SelectCommand="select label_id, label_name from dl_label order by label_name asc"        ConnectionString="<%$ConnectionStrings:streetwisedigitalConnectionString%>">    </asp:SqlDataSource>    <div>        <table>            <tr>                <td>Start Date:&nbsp;</td>                <td>                    <asp:TextBox ID="FromDate" Runat="server" Width="70"/>                    <asp:Button ID="btnFrom" Runat="server" Text="..." UseSubmitBehavior="false" />                </td>            </tr>            <tr>                <td>End Date:&nbsp;</td>                <td>                    <asp:TextBox id="ToDate" Runat="server" Width="70" />                    <asp:Button ID="btnTo" Runat="server" Text="..." UseSubmitBehavior="false" />                </td>            </tr>            <tr>                <td>Label:&nbsp;</td>                <td>                    <asp:DropDownList ID="LabelList" Runat="server"                     DataSourceID="SqlDataSourceLabels"                     DataTextField="label_name" DataValueField="label_name">                    </asp:DropDownList>                </td>            </tr>            <tr>                <td colspan="2" align="right">                    <asp:Button ID="Button1" OnClick="SubmitButton_OnClick" Text="View Sales" runat="server" />                </td>            </tr>        </table>        <p>            <asp:GridView ID="GridViewSales" runat="server"                 DataSourceID="SqlDataSourceSales"                 ShowFooter="True"                 AllowSorting="True"                 AutoGenerateColumns="False"                 OnRowDataBound="GridViewSales_RowDataBound" EmptyDataText="No data to display.">                <Columns>                    <asp:BoundField DataField="cat_no" HeaderText="Cat No" />                    <asp:BoundField DataField="artist" HeaderText="Artist" />                    <asp:BoundField DataField="title" HeaderText="Title" />                    <asp:BoundField DataField="remix" HeaderText="Remix" />                    <asp:BoundField DataField="qty" HeaderText="Sold" />                    <asp:boundfield datafield="commission"                        HtmlEncode="False"                         dataformatstring="{0:F2}"                          headertext="Commission">                        <ItemStyle HorizontalAlign="Right" />                    </asp:boundfield>                </Columns>            </asp:GridView>        </p>    </div></asp:Content>code behind...using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class LabelSales : System.Web.UI.Page{    int totalSold;    decimal totalCommssion;    protected void GridViewSales_RowDataBound(object sender, GridViewRowEventArgs e)    {        // add column totals to gridview        if (e.Row.RowType == DataControlRowType.DataRow)        {            totalSold += (int)DataBinder.Eval(e.Row.DataItem, "qty");            totalCommssion += (decimal)DataBinder.Eval(e.Row.DataItem, "commission");        }        // display the totals        else if (e.Row.RowType == DataControlRowType.Footer)        {            e.Row.Cells[0].Text = "<b>Total</b>";            e.Row.Cells[4].Text = totalSold.ToString();            e.Row.Cells[5].Text = totalCommssion.ToString("f2");        }    }        protected void Page_Load(object sender, EventArgs e)    {                   }    protected void SqlDataSourceSales_Selecting(object sender, SqlDataSourceSelectingEventArgs e)    {        // *** This method does not work ***        e.Command.Parameters[0].Value = FromDate.Text;        e.Command.Parameters[1].Value = ToDate.Text;        e.Command.Parameters[2].Value = LabelList.Text;        // *** This method works! ***        e.Command.Parameters[0].Value = "02/01/2007";        e.Command.Parameters[1].Value = "02/01/2008";        e.Command.Parameters[2].Value = "Fat!";    }    protected void SubmitButton_OnClick(object sender, EventArgs e)    {        SqlDataSourceSales.Select(DataSourceSelectArguments.Empty);    }}  Many thanks  Simon 

View 3 Replies View Related

How Do I Populate A TextBox With A SqlDataSource Control? (asp.net 2.0 Question)

Jan 17, 2008

Beginner question, I know -- but in ASP.NET 2.0, I can't figure out (or find out) how to populate a TextBox with data from the db using a SqlDataSource control (without using a formview control)???
Any help would be greatly appreciated!!

View 4 Replies View Related

Inserting TextBox Values To Database Using SqlDataSource.Insert Method

Oct 25, 2006

Hi, it is few days I posted here my question, but received no answer. Maybe the problem is just my problem, maybe I put my question some strange way. OK, I try to put it again, more simply. I have few textboxes, their values I need to transport to database. I set SqlDataSource, parameters... and used SqlDataSource.Insert() method. I got NULL values in the database's record. So I tried find problem by using Microsoft's sample code from address http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.insert.aspx. After some changes I tried that code and everything went well, data were put into database. Next step was to separate code beside and structure of page to two separate files followed by new test. Good again, data were delivered to database. Next step: to use MasterPage, very simple, just with one ContentPlaceHolder. After this step the program stoped to deliver data to database and delivers only NULLs to new record. It is exactly the same problem which I have found in my application. The functionless code is here:http://forums.asp.net/thread/1437716.aspx I cannot find any answer this problem on forums worldwide. I cannot believe it is only my problem. I compared html code of two generated pages - with maserPage and without. There are differentions in code in ids' of input fields generated by NET.Framework:Without masterpage:<input name="NazevBox" type="text" id="NazevBox" /><span id="RequiredFieldValidator1" style='color:Red;visibility:hidden;'>Please enter a company name.</span><p><input name="CodeBox" type="text" id="CodeBox" /><span id="RequiredFieldValidator2" style='color:Red;visibility:hidden;'>Please enter a phone number.</span><p><input type="submit" name="Button1" value="Insert New Shipper" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;Button1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="Button1" /> With masterpage:<input name="ctl00$Obsah$NazevBox" type="text" id="ctl00_Obsah_NazevBox" /><span id="ctl00_Obsah_RequiredFieldValidator1" style='color:Red;visibility:hidden;'>Please enter a company name.</span><p><input name="ctl00$Obsah$CodeBox" type="text" id="ctl00_Obsah_CodeBox" /><span id="ctl00_Obsah_RequiredFieldValidator2" style='color:Red;visibility:hidden;'>Please enter a phone number.</span><p><input type="submit" name="ctl00$Obsah$Button1" value="Insert New Shipper" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$Obsah$Button1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="ctl00_Obsah_Button1" />In second case ids' of input fields have different names, but I hope it is inner business of NET.Framework.There must be something I haven't noticed, maybe NET's bug, maybe my own. Thanks for any suggestion.

View 2 Replies View Related

ControlParameter

Jan 23, 2008

I am new to asp.net and this is the first time I have tried to use a ControlParameter from another control and I can not get it to work. FormView1 works as expected, but the controlParameter in SqlDataSource2 does not work as expected.
 A part of FormView1 and SqlDataSource1 (the source)<asp:FormView ID="FormView1" runat="server" DataKeyNames="Id"
DataSourceID="SqlDataSource1"
<ItemTemplate>
<asp:Label ID="lblCategoryName" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Id], [CategoryName], [ItemNumber], [Name], [Price], [SalePrice], [FullDescription], [ImageAltText], [DateSold] FROM [Products] WHERE ([Id] = @Id)">
<SelectParameters>
<asp:QueryStringParameter Name="Id" QueryStringField="Id" DefaultValue="11" />
</SelectParameters>
</asp:SqlDataSource>
 
SqlDataSource2 (where I need to use "lblCategoryName" from FormView1) <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Id], [CategoryName], [ImageAltText], [DateSold] FROM [Products] WHERE ([CategoryName] = @CategoryName)">
<SelectParameters><asp:ControlParameter ControlID="FormView1"
DefaultValue="Earrings" Name="lblCategoryName"
PropertyName="text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
I hope someone can help me with my simple problem.
Thank you

View 1 Replies View Related

How To Refer To Report Textbox Values In Another Textbox

May 24, 2007

I want to add up the values in a couple of text boxes in another textbox. How do I refer to the textboxes?



fields!textbox1.value doesn't work..what does?

View 1 Replies View Related

Set ControlParameter To Todays Date (vb)

Dec 21, 2006

Hi,I have the following sqldatasource on my page:<asp:SqlDataSource ID="rs1" runat="server" ConnectionString="<%$ ConnectionStrings:FrogConnectionString %>" SelectCommand="Proposals_DaySheet" SelectCommandType="StoredProcedure"><SelectParameters><asp:ControlParameter ControlID="Calendar1" Name="FilterDate" PropertyName="SelectedDate" Type="DateTime" DefaultValue=""/></SelectParameters></asp:SqlDataSource>How do I set the default value to today's date ?I have tried:DefaultValue="<%# DateTime.Now %>"But I get:Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.ControlParameter does not have a DataBinding event.I have also tried:DefaultValue="<%= DateTime.Now %>"But I get:System.FormatException: String was not recognized as a valid DateTime.Any ideas ?ThanksJames
 

View 4 Replies View Related

How To Specify 2 Different Selectparameters - 1 For Querystringparameter And 1 For Controlparameter

Apr 4, 2007

Hello,
I am sure there is a way to do this programmatically, but it is just not sinking in yet on how to go about this.  I have a page where I use a dropdownlist that goes into a gridview and then the selected item of the gridview into the detailsview (typical explain seen online).  So, when selecting from the dropdownlist, the gridview uses a controlparameter for the selectparameter to display the appropriate data in the gridview (and so on for the detailslist). 
My question is - I wanted to use this same page when coming in from a different page that would utilize querystring.  So, the parameter in the querystring would be for what to filter on in the gridview, so the dropdownlist (and that associated controlparameter) should be ignored.
Any suggestions on how to go about this?  I assume there is some check of some sort I should in the code (like if querystring is present, use this querystringparameter, else use the controlparameter), but I am not sure exactly what I should check for and how to set up these parameters programmatically.
 Thanks,
Jennifer

View 5 Replies View Related

ControlParameter And Stored Procedures

Apr 2, 2006

I'm sure I'm missing something silly.  I have 3 textboxes, a stored procedure and a gridview.  The user will put something in the 3 boxes, click submit, and see a grid with stuff (I hope).  However, the grid will only return data is I EXCLUDE the controlparameters and only use the sessionparameter.  It's like the stored proc won't even fire!
HTML:
<form id="form1" runat="server"><div>Lastname:&nbsp;<asp:textbox id="Lastname" runat="server"></asp:textbox>Hobbies:&nbsp;<asp:textbox id="Hobbies" runat="server"></asp:textbox><br />Profession:&nbsp;<asp:textbox id="Profession" runat="server"></asp:textbox><asp:button id="Button1" runat="server" text="Button" /><br /><asp:gridview skinid="DataGrid" id="GridView1" runat="server" allowpaging="True" allowsorting="True" autogeneratecolumns="False" datasourceid="SqlDataSource1"><columns><asp:boundfield datafield="Username" headertext="Username" sortexpression="Username" /><asp:boundfield datafield="Lastname" headertext="Lastname" sortexpression="Lastname" /><asp:boundfield datafield="Firstname" headertext="Firstname" sortexpression="Firstname" /></columns></asp:gridview>
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:HOAConnectionString %>"selectcommand="spAddressBookSelect" selectcommandtype="StoredProcedure"><selectparameters><asp:sessionparameter defaultvalue="0" name="CommunityID" sessionfield="CommunityID" type="Int32" /><asp:controlparameter controlid="Lastname" name="Lastname" propertyname="Text" type="String" /><asp:controlparameter controlid="Profession" name="Profession" propertyname="Text" type="String" /><asp:controlparameter controlid="Hobbies" name="Hobbies" propertyname="Text" type="String" /></selectparameters></asp:sqldatasource>
</div>
</form>
sp signature:ALTER PROCEDURE [dbo].[spAddressBookSelect] @CommunityID int = 0,@Lastname varchar(200) = NULL,@Profession varchar(200) = NULL,@Hobbies varchar(200) = NULL

View 2 Replies View Related

How To Progtammatically Manipulate Property 'Name' Of ControlParameter?

Jun 7, 2007

Hi,
i want to programmatically manipulate the property 'Name' of a ControlParameter inside a InsertParameters tag.
This the aspx code: ------------------  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<% ......... %>"         InsertCommand="INSERT INTO .......)"            <InsertParameters>            <asp:ControlParameter Name="myname" ControlID="na" PropertyName="text" />           </InsertParameters>         </asp:SqlDataSource>
code-behind: ------------
Dim a As String         a = SqlDataSource1.InsertParameters.Item(0).ToString
but 'm stuck here
Thanks for help
Tartuffe

View 1 Replies View Related

Load ControlParameter From Page's Peoperties

Feb 25, 2008

Hi,in aspx I've SqlDataSource, in SelectParametersI can add ControlParameter and to load parametersfrom control Property, BUT I'm trying to do that:Is there way, when in <ControlParameter>to set parameter to be loaded from PAGE Property.something like that:aspx:<asp:SqlDataSource ID="_companyDS" runat="server"   ConnectionString="<%$ ConnectionStrings:tihomir_dbConnectionString %>"   SelectCommand="SELECT [companyID], [companyName], [companyInfo], [companyAddress] FROM [Companies] WHERE ([companyID] = @companyID)">   <SelectParameters>     <asp:ControlParameter ControlID="Page" PropertyName="CompanyIdent" Name="companyID" Type="Int32" DefaultValue="0" />   </SelectParameters>    </asp:SqlDataSource></asp:SqlDataSource>code behind:public partial class test : System.Web.UI.Page{   public int CompanyIdent   {      get      {         return ... some id ...;      }   }}  Best Regards,Tihomir Ivanov Best Manager Software

View 2 Replies View Related

Sending Multiple Values From A ListBox To ControlParameter

Dec 15, 2005

Any ideas on how I can send multiple values from a listbox to a stored procedure?  right now I have a ListBox Control called lbCategory, and I want to pass multiple selected items to a stored procedure.  
<asp:SqlDataSource ID="dsFS" runat="server" ConnectionString="someConnectionString" SelectCommand="usp_FS" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="lbCategory" DefaultValue="%" Name="category" PropertyName="SelectedValue" type="String" />
</SelectParameters>
</asp:SqlDataSource>

View 5 Replies View Related

Can A ControlParameter Be Used To Supply A Parameter For A Stored Procedure?

Apr 13, 2006

The code below is an attempt at using the value from a dropdownlist to feed into stored procedure outlined in the Select command. I have seen examples where the control parameter is used with a select command but nothing where the parameter has to be fed into a stored procedure.
 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=".."SelectCommand="procCAGetCustomerKPIs" SelectCommandType="StoredProcedure"><SelectParameters><asp:ControlParameter Name="iCustomerGroupId" ControlID="CustomerFilterList" PropertyName="SelectedValue" /></SelectParameters></asp:SqlDataSource>
 
cheers-jim.

View 2 Replies View Related

Reference Textbox In Other Textbox

Sep 12, 2007

Hi!
I dont know if i will explain this correctly, but my problem is with reporting service.
I'm supposed to Sum value in one textbox and than that sum use it in sum in other textbox.

Something like this:
Sum(Fields!Abc.Value/(Fields!dfg.Value+Sum(Fields!abc.Value)),"matrix1_RowGroup1")*100
I get error msg 'The Value expression for the textbox 'textbox49' contains an aggregate function (or RunningValue or RowNumber functions) in the argument to another aggregate function (or RunningValue). Aggregate functions cannot be nested inside other aggregate functions.'

Something like this wont work either Sum(Fields!abc.Value/ReportItems("textbox56").Value)*100
Error The Value expression for the textbox 'textbox55' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers.

So, pls help if you know how to reference textbox in other in body of report.
Thx.

View 1 Replies View Related

SELECT A Single Row With One SqlDataSource, Then INSERT One Of The Fields Into Another SqlDataSource

Jul 23, 2007

What is the C# code I use to do this?
I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.

View 7 Replies View Related

Individual SqlDataSource() Or Common SqlDataSource() ?

Mar 8, 2007

i am using visual web developer 2005 with SQL Express 2005 with VB as the code behindi have one database and three tables in itfor manipulating each table i am using separate SqlDataSource() is it sufficient to use one SqlDataSource() for manipulating all the three tables ? i am manipulating all the tables in the same page only please help me

View 1 Replies View Related

Textbox

Oct 4, 2007

I have several textbox on my report and I would like to remove line if blank.

texbox1
textbox2 <--- use Expression in order to display it.
textbox3

------------------------------------------------------------------------------
Current Display :

sergio myers


<-------- insert a blank line
donna summer

_____________________________________________
The Desire Result that I would like to have :
sergio myers
donna summer
_____________________________________________
I would like to remove the middle line if blank so it can be display like this :
sergio myers
donna summer

Does anybody knows how to accomplish this in Reporting Services.
Foxpro uses "Remove line if blank" and 'Print only when expression is true'

Thanks,
Sergio

View 10 Replies View Related

Several Keywords In The Same Textbox

Dec 27, 2006

Hey
 I got a SQL DB with three tables, where two of the collums of the main table gets its data from two other tables, ok? Now, on one page, called "search"  the user should be able to search in the DB, and on another page the user should be able to register some keywords, my question is how can the user register several keywords in the same textbox, using perhaps a ; as a separator between the words? I hope you understand what I mean..
 
Thx!
 

View 2 Replies View Related

Updating Using Textbox In VB

Jan 29, 2008

Hello
 How do u update the datafield of a row using buttonClick in vb? I have a details view whereby it will display the username and timeleft once log in. currently the datafield, timeleft on one user in the database is null. I'm using sqldatasource.
Once log in, it will direct to this page where the user enters a code on the textbox and click the enter button. This will cause an update on the user's timeleft. But the code must not be entered to the database.
 For eg. If code = 1111 then 'update timeleft = 60 The timeleft is in minutes. 60 will be stored as double in the user's row in the database. How do i do this?
Please help asap. Thanks! :)

View 3 Replies View Related

How Can I Input A Sql Value To A Textbox ?

Feb 4, 2008

I use txtbox.Text = cmd.ExecuteReader() but it doesn't work.  How can I fix it ? 

View 4 Replies View Related

Updating Textbox?

May 16, 2008

 HelloI have a problem when I want to update my textbox, I have a textbox called Textbox1, when I Insert data from it to database it is working well, even when I Update it WITHOUT SELECT field from database it is working well again,but when I Select [pagename] from database then want to Update it it is not working, nothing happend and in debuging the textbox doesnt have any value. what shoud i do? the value become null?    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        Label1.Text = Request("Id").ToString()        Dim conname As String = ConfigurationManager.ConnectionStrings("IPbrandConnectionString").ConnectionString()        Dim con As New SqlConnection(conname)        Dim sql As String = "SELECT [Id], [pagename] FROM [content] WHERE ([Id] = @Id)"        Dim cmd As New SqlCommand(sql, con)        cmd.Parameters.Add(New SqlParameter("@Id", SqlDbType.Int, 32))        cmd.Parameters("@Id").Value = Label1.Text.ToString()        con.Open()        Dim reader As SqlDataReader = cmd.ExecuteReader()        Do While reader.Read()            TextBox1.Text = reader("pagename")           Loop        reader.Close()        con.Close()    End Sub  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim conname1 As String = ConfigurationManager.ConnectionStrings("IPbrandConnectionString").ConnectionString()        Dim con1 As New SqlConnection(conname1)        Dim sql1 As String = "UPDATE [content] SET [pagename] = @pagename WHERE [Id] = @Id "        Dim cmd1 As New SqlCommand(sql1, con1)        cmd1.Parameters.Add(New SqlParameter("@Id", SqlDbType.Int, 32))        cmd1.Parameters("@Id").Value = Label1.Text.ToString()        cmd1.Parameters.Add(New SqlParameter("@pagename", SqlDbType.VarChar, 50))        cmd1.Parameters("@pagename").Value = TextBox1.Text.ToString()        cmd1.UpdatedRowSource = UpdateRowSource.OutputParameters        Try            con1.Open()            cmd1.ExecuteNonQuery()        Catch err As SqlException            Throw New ApplicationException("Data error.")        Finally            con1.Close()        End Try        Server.Transfer("main.aspx")

View 2 Replies View Related

SELECT TOP (textbox Value)

Jul 5, 2005

Is it possible to do this as i want to select the top based on the value i enter in the textbox. usually we using this

SELECT TOP 10 * FROM Customers

But i want the value is get from my textbox.

View 1 Replies View Related

Textbox Issue

Mar 15, 2008

Hey guys, I am trying to create a report which features a lot of textboxes side by side, but I have the problem that even though they are the same size when the textboxes are placed side by side or above or below another textbox and then the preview tab is selected they often look different for example they may not be aligned correctly or the borders look thicker in different textboxes.

Is there a solution for this issue?

Many thanks.

View 4 Replies View Related







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