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


ADVERTISEMENT

SqlDataSource Setting Of Parameters?

Aug 29, 2007

Hi,How do I set the parameters of an SqlDataSource programatically?I have tried the following...dsDraftBudgetPI.SelectParameters.Add(new Parameter("@person_id", TypeCode.Int32, pID.ToString()));But that didn't work.  I already have the parameter defined at design time so I don't need to create one I just want to set its value and then bind it to a ListBox to display the result.Thanks,Scott 

View 3 Replies View Related

Setting Command Parameters For SQLDataSource

Dec 26, 2007

I have an SQLDataSource. The SQL is
 SELECT UserName, Category, ItemDescription, Size, Price, Reduce, Donate, Sold, ItemNumber, SoldDate, SoldPrice, PrintedFROM Tags WHERE (Printed = @Printed1 OR Printed = @Printed2 OR Printed = @Printed3) ORDER BY ItemNumber DESCThe bit field "printed" can be NULL, True or False.In the Selecting event of the SQLDataSource I have the following to show ALL records. But it does not work. If I remove these parameters it show ALL records.
e.Command.Parameters("@Printed1").Value = Nothing           'ASP.NET 2.0 using Visual basice.Command.Parameters("@Printed2").Value = Truee.Command.Parameters("@Printed3").Value = False
What am I doing wrong???
Thanks
Craig

View 10 Replies View Related

Setting SqlDataSource Update Command And Parameters Dynamically C#

Aug 31, 2007

Hello all,
Ok, I finally got my SqlDataSource working with Oracle once I found out what Oracle was looking for. My next hurdle is to try and set the Update Command and Parameters dynamically from a variable or radiobutton list. What I'm trying to accomplish is creating a hardware database for our computers by querying WMI and sending the info to textboxes for insertion and updating. I got that part all working nicely. Now I want to send the Computer name info to a different table column depending on if it is a laptop or desktop. I have been tossing around 2 ideas. A radiobutton list to select what it is and change the SQL parameters or do it by computer name since we have a unique identifier as the first letter ("W" for workstation, "L" for Laptop). I'm not sure what would be easiest but I'm still stuck on how this can be done. I posted this same question in here a few days ago, but I didn't have my SqlDataSources setup like I do now, I was using Dreamweaver 8, it is now ported to VS 2005. Below is my code, in bold is what I think needs to be changed dynamically, basically i need to change DESKTOP to LAPTOP...Thanks for all the help I've gotten from this forum already, I'm very new to ASP.NET and I couldn't do this without all the help. Thanks again!
 
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CAT %>"ProviderName="<%$ ConnectionStrings:CAT.ProviderName %>" SelectCommand='SELECT * FROM "COMPUTER"' UpdateCommand="UPDATE COMPUTER SET DESKTOP = :DESKTOP, TECH = :TECH, SERVICE_TAG = :SERVICE_TAG WHERE USERNAME=:USERNAME">
<UpdateParameters>
<asp:ControlParameter Name="USERNAME" ControlId="txtUserName" PropertyName="Text"/>
<asp:ControlParameter Name="SERVICE_TAG" ControlId="txtServiceTag" PropertyName="Text"/>
<asp:ControlParameter Name="TECH" ControlId="txtTech" PropertyName="Text"/>
<asp:ControlParameter Name="DESKTOP" ControlId="txtComputerName" PropertyName="Text"/>
</UpdateParameters>
</asp:SqlDataSource>

View 1 Replies View Related

Setting Visibility Of Textbox

Jan 19, 2007

Hi All,

I have the following requirement:

I have an output like this:









Country
State
Measure

USA
WA
1000


OR
2000

Canada
BC
300

India
TN
200


AP
400

I am using a matrix where country and state are on rows.

I want to set the visibility of the textbox containing the value of the state column based on the number of states a country has.

I would like the output to be like this: If the country has only one state, then the state name should be blank.









Country
State
Measure

USA
WA
1000


OR
2000

Canada

300

India
TN
200


AP
400



Something like iif(count(state) for a country)==1,false,true)

Please let me know how to achieve this in SSRS.

Thanks in advance

Arun

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

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

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

Display Multi Value Parameters In Textbox

Jun 8, 2007

Hello,



I have the following problem.

i have a report where you need to fill in a few parameters

start date, end date and subject selection.

the subject selection is a multivalue paramter (select all, param1, param2, param3)

the multivalue parameter is based on another dataset with paramid as value field and paramdescription as value label.



in my report i want to display something like this :

from startdate to enddate

summary for campaign(s) : selected parameters.



in the selected parameters is can display a =join(Parameter!campaig.value) but this only returns the 32bit guid.

instead i would like it to display the parameterdescription label.



anybody has some ideas ?



greetings

vince

View 1 Replies View Related

Binding Stored Procedure OUTPUT Parameters To A TextBox, How?

Oct 11, 2004

Hi all;

How can I show the Name & Age of the selected student's ID in the appropriate TextBox(s) (txtName & txtAge)?

BTW:

My "ShowStudent" stored procedure:

ALTER PROCEDURE ShowStudent
@ID int
AS
SELECT ID, Name, Age FROM Student WHERE ID=@ID
RETURN



And this is the code for "Show" button:

' Which SP? Connection?
Dim cmdSelect As New SqlCommand("ShowStudent", con)
cmdSelect.CommandType = CommandType.StoredProcedure

'-----[ Spacifay SP parameters ]-----

'ID
cmdSelect.Parameters.Add("@ID", SqlDbType.Int, 4)
cmdSelect.Parameters("@ID").Value = CType(txtID.Text, Integer)

'Open Connection
con.Open()



'-----[ Execute the select command ]-----

cmdSelect.ExecuteReader()


'----------------------------------------

'Close connection
con.Close()

'========================================================
End Sub




So, do I have to use an OUTPUT parameter in the stored procedure? If Yes, How to get its (the parameter) value and bind it to the appropriate TextBox?

Hope my question is clear!!

Thanks in advanced!

View 6 Replies View Related

Setting The SelectParameters Of SqlDataSource

Dec 30, 2005

Hi All,
I'm trying to set the SelectParameters of SqlDataSource from the code behind.
This is my query: SELECT * FROM [UploadSessions] WHERE ([OwnerID] = @OwnerID)And I need to set the value of the @OwnerID at the code behind since it is stored in an object.
How can I do it??
Thanks in advance
Bar
 

View 7 Replies View Related

Setting The Value Of A SqlDataSource.SelectParameter Object

Sep 13, 2006

I am trying to set the value of a SqlDataSource parameter named "InvestmentGroup" with the following code:ProjectData.SelectParameters["InvestmentGroup"] = Request.QueryString[0];ProjectData.DataBind();When I try this, I get an error saying that the right side is a string and the left side is not....but I cannot find a property of the SelectParameters["InvestmentGroup"] object like Value or something that would allow me to set the value of the parameter with a string. Please help!

View 4 Replies View Related

Programmatically Setting UpdateParameters For A SQLDataSource Control

Sep 8, 2006

I need to provide defaults and sometimes overrides for items in SQLDataSource's UpdateParameters. I am attempting to do this in a FormView's ItemUpdating and ItemInserting events as follows: //========================================================================
// FormView1_ItemUpdating:
//========================================================================
protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) {
// not sure if this is the bets place to put this or not?
dsDataSource.UpdateParameters["UpdatedTS"].DefaultValue = DateTime.Now.ToString();
dsDataSource.UpdateParameters["UpdatedUserID"].DefaultValue = ((csi.UserInfo)Session["UserInfo"]).QuotaUserID;
}
 In the example above I am attempting to set new values for the parameters which will replace the existing values. I have found that using the DefaultValue property works ONLY if there is no current value for the parameter.  Otherwise the values I specify are ingnored.The parameters of an ObjectDataSource provide a Value property but SQLDataSource parameters do not.How can I provide an override value without needing to place the value in the visible bound form element???If you can answer this you will be the FIRST person ever to answer one of my questions here!!!Thanks,Tony 

View 2 Replies View Related

Need Help Setting Default DateTime On SqlDataSource Control

Jan 21, 2007

I thought this would be easy.  I have a repeater control and a sqldatasource control.  I am trying to filter the select statement using DateTime.Now.ToString() and keep getting an invalid date string format.  The control is on a content page in my asp.net site.  On the master page this <%= DateTime.Now.ToLongDateString() %>  works to display the current date.  If I try and put <%= DateTime.Now.ToString() %> in the Default value of the SelectParameter it does not work.  No intellisense either so I am assuming I am missing something.  Here is the code... pretty basic really.
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="sqlDSnews">
<ItemTemplate>
<h3><%# Eval("newTitle")%></h3>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource
ID="sqlDSnews"
runat="server"
ConnectionString="<%$ ConnectionStrings:XXXX%>"
SelectCommand="SELECT [newTitle], [newsDetails], [dateExpires], [newsImage], [dateCreated] FROM [News] WHERE (([GroupID] = @GroupID) AND ([dateExpires] >= @dateExpires))">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="0" Name="GroupID" QueryStringField="Gid" Type="Int32" />
<asp:Parameter Name="dateExpires" DefaultValue='<%= DateTime.Now.ToString() %> 'Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
** NOTE the DateTime does not show up in blue - if that helps with a solution **

View 5 Replies View Related

SqlDataSource SelectCommand - Dynamically Setting The Name Of The Table?

May 7, 2007

Can you dynamically set the name of the table in the SelectCommand section of the SqlDataSource? (If it is relevant, I code in C#)
 For example,
<asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:Test-MySQL %>" ProviderName="<%$ ConnectionStrings:Test-MySQL.ProviderName %>" SelectCommand="SELECT * FROM TestTable">
I would like to replace 'TestTable' with the name of a table that is extracted from a string array in the code-behind.
Appreciatively,Peter

View 4 Replies View Related

Sqldatasource Setting Reset After Page Postback, Could Anyone Give Me A Hand On This

Nov 25, 2005

Hi, I have created a search page which needs to perform different
search function in same page. I have setuped a sqldatasource then
manual
setup the connection string and command inside the codefile. So the
select command can be various depends on the event. The problem is
all of those setting will be reset after I click on the pageindex in
the girdview control to go to next pages. Since this gridview is linked

with this sqldatasource control, I need to restore the connection
string/command when user choose decide to view next page of data inisde
the
gridview.

I think I must have done something wrong in here becuase it will end up
retrieving  the total amount of data when everytime user choose to
view next
or perivous page.

Can someone give me a hand on this ? Thanks

View 1 Replies View Related

Setting Parameters @ Runtime

Jan 24, 2006

Here is the code I am trying to use to set a update parameter at runtime.  (Depending on what linkbutton a user clicks on the STATUS_ID value will change.)
SqlDataSource1.UpdateParameters("STATUS_ID").DefaultValue = 33332Here are my parameters:
<UpdateParameters>
<asp:Parameter Name="CUSTOMER_ID" Type="Decimal" />
<asp:Parameter Name="RECEIVED_BY" Type="String" />
<asp:Parameter Name="CALL_DATETIME" Type="DateTime" />
<asp:Parameter Name="AREA_ID" Type="Decimal" />
<asp:Parameter Name="CLASS_ID" Type="Decimal" />
<asp:Parameter Name="STATUS_ID" Type="Decimal" /></UpdateParameters>Sqldatasource1 is the name of my datasource control.  Any thoughts?

View 2 Replies View Related

SqlDataSource Parameters

Apr 4, 2007

Is
it possible to specify different parameters for the
select/update/delete stored procedures used by a sqldatasource? When I
'configure the datasource' it lists the different stored procedures for
each command, but when it comes to specifying the parameters it only
lets me do so for the select command. Is there another way to do this
for the other commands?

I have tried doing it manually in the aspx file (using the
DeleteParemeters etc), but I don't know how to reference a specific
cell in the selected row of the gridview for the controlparameter). Any
thoughts?

View 4 Replies View Related

Parameters Of SqlDataSource

Apr 17, 2007

Hello I need help withsetting parameters for SqlDataSource
I have a simple program. I want display date from  database on MS SQLSERVER from the table USERS only for  current sing on user select by his login.
 I save into this  variable login current user:   string @LOGIN = Context.User.Identity.Name;
I have already done with this way without SqlDataSource:
string login = Context.User.Identity.Name;
SqlConnection conn1 = new SqlConnection("server=CR\SQLEXPRESS;database=myData;integrated security=SSPI");
conn1.Open();
SqlCommand cmd1 = new SqlCommand(" SELECT  IN_OUT.TIME_START,  IN_OUT.TIME_END, FROM  IN_OUT INNER JOIN USER ON USER.USER_ID=IN_OUT.RC_USER_ID where USER.LOGIN=@LOGIN", conn1);
cmd1.Parameters.Add("@LOGIN", SqlDbType.NVarChar, 50);
cmd1.Parameters["@LOGIN"].Value = login;
1.Parameters.Add("@LOGIN", SqlDbType.NVarChar, 50);
cmd1.Parameters["@LOGIN"].Value = login;
Now I don't know how to do with SqlDataSource, what I have to set in SqlDataSource1 yet
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
ProviderName="<%$ ConnectionStrings:myConnectionString.ProviderName %>" SelectCommand="SELECT IN_OUT.TIME_START, IN_OUT.TIME_END, FROM IN_OUT INNER JOIN USER ON USER.USER_ID=IN_OUT.RC_USER_ID where USER.LOGIN=@LOGIN">
</asp:SqlDataSource>

View 1 Replies View Related

Parameters.Add With SqlDataSource

Dec 2, 2007

Does anybody knows how to use parameters.add with SqlDataSource?

View 4 Replies View Related

How To Value Parameters For Sqldatasource

Dec 9, 2007

I set up a sqldatasource based on a stored procedure which takes one parameter.  The sqldatasrouce wizard generates the following code for the parameter below.  The question is how do I value the DeptID parameter on the load of the form.  I tried the following code in the load of the page, but get a null reference error:Me.SqlDataSource1.InsertParameters("DeptID").DefaultValue = Session("DeptID")     <asp:SqlDataSource ID="SqlDataSource1" runat="server"             ConnectionString="<%$ ConnectionStrings:FDConn %>"             SelectCommand="GetTruckStatus" SelectCommandType="StoredProcedure">            <SelectParameters>                <asp:Parameter Name="DeptID" Type="Int32"  />            </SelectParameters>        </asp:SqlDataSource>        <radG:RadGrid ID="RadGrid1" runat="server">        </radG:RadGrid>

View 3 Replies View Related

SQLDataSource: How To Use Parameters

Dec 22, 2005

I need to do some select & update from VB code behind a web page. Using VS2005, ASP.NET.
To me, the most logical approach would be to use a SqlDataSource. I can select the connection string, predefine select, insert and update queries and call the select(), and other commands from this control.
I need to use parameters in the queries but I cannot connect parameters straight to controls, I need to do it from VB. But nowhere can I find how to set the parameter values from code. I can find all kind of examples from VS2003 or using SqlCommand, but it should be possible from this control as well, but the help documentation is very poor in this respect.
Please provide me with some example.
Kind regards
 

View 5 Replies View Related

Getting Error When Setting Parameters Dynamically

Feb 5, 2008

Hi All,

I am creating the report and setting the datasource(dataset) dynamically to the report. I want to set the parameters also dynamically. am using Report Viewer to process the report.


When i set the parameters locally, i am getting the below error:
An error occurred during local report processing


Here is my code:
da = new SqlDataAdapter(strqry, conn);
ds = new DataSet();
da.Fill(ds);

ReportDataSource ReportDataSourceX = new ReportDataSource();
ReportDataSourceX.Value = ds.Tables[0];
ReportParameter[] parm = new ReportParameter[2];

parm[0] = new ReportParameter("Business_Function", "SQMO");
parm[1] = new ReportParameter("Application", "ETMRS");
parm[0] = new ReportParameter("Owner", "Subbu");
//parm[0] = new ReportParameter("Business_Function", ds.Tables[0].Columns["Business_Function"].ToString());
//parm[1] = new ReportParameter("Application", ds.Tables[0].Columns["Application"].ToString());
//parm[0] = new ReportParameter("Owner", ds.Tables[0].Columns["Owner"].ToString());

RptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;

RptViewer.LocalReport.ReportPath = "C:\ETMRS Reporting\ETMRS Reports\ETMRS Reports\PlannedTestCasesSummary.rdl";
//RptViewer.LocalReport.SetParameters(parm);

RptViewer.LocalReport.DataSources.Add(ReportDataSourceX);
RptViewer.LocalReport.SetParameters(parm);
RptViewer.LocalReport.Refresh();


Can anyone please help me in resloving this issue.

Thanks in advance,
SR.

View 9 Replies View Related

Setting SQlServer Parameters Progamatically

Mar 10, 2008



I'm trying to figure out how I might be able to enable IP1 and IP2 through something like Visual Basic.
I've looked into SMO, I don't see that it lets you access that level of configuration. Is there any way to set configuration values like this other than through the GUI?

View 2 Replies View Related

Setting Multi-value Parameters Using ReportExecutionService

Apr 24, 2007

Does anyone know how to set multi-value parameters using ReportExecutionService in C#?



If I have



rsExec = new ReportExecutionService2005.ReportExecutionService();

.

.

.

ReportExecutionService2005.ParameterValue[] parameters = new ReportExecutionService2005.ParameterValue[2];



parameters[0] = new ReportExecutionService2005.ParameterValue();

parameters[0].Label = "Report_Begin_Date";

parameters[0].Name = "Report_Begin_Date";

parameters[0].Value = "4/15/2007";



parameters[1] = new ReportExecutionService2005.ParameterValue();

parameters[1].Label = "SalesID";

parameters[1].Name = "SalesID";

parameters[1].Value = ??? //Here, this parameter should accept multiple values like 200, 201, 202, etc.



rsExec.SetExecutionParameters(parameters, "en-us");



How would I set the SalesID to take multiple values?

View 12 Replies View Related







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