C# - Two Dates Parameters In SQL Function

Mar 16, 2011

I have a page like this In my SQL, I want calculate some value between these days And this is my code;

strQuery = @"SELECT B.HESAP_NO, A.TEKLIF_NO1 + '/' + A.TEKLIF_NO2 AS 'TEKLIF',
B.MUS_K_ISIM, CONVERT(VARCHAR(10),A.ISL_TAR,103) AS 'TARIH',
SUM(ISNULL(CAST(A.ODENEN_ANAPARA AS FLOAT),0)+ISNULL(CAST(A.FAIZ AS FLOAT),0)+
ISNULL(CAST(A.BSMV AS FLOAT),0)+ISNULL(CAST(A.GECIKME_FAIZ AS FLOAT),0)+
ISNULL(CAST(A.GECIKME_BSMV AS FLOAT),0)) AS 'YATAN',
(CASE WHEN B.DOVIZ_KOD = 21 THEN 'EUR' WHEN B.DOVIZ_KOD = 2 THEN 'USD' WHEN B.DOVIZ_KOD = 1 THEN 'TL' END) AS 'KUR',
D.AVUKAT,
(CASE WHEN D.HESAP IN (SELECT T_HESAP_NO FROM TAKIP) THEN
(SELECT ICRA_TAR FROM TAKIP WHERE T_HESAP_NO = D.HESAP)
ELSE ' ' END) AS 'ICRA TARİHİ',
(CASE WHEN D.HESAP IN (SELECT T_HESAP_NO FROM TAKIP) THEN
(SELECT HACIZ_TAR FROM TAKIP WHERE T_HESAP_NO = D.HESAP)
ELSE '' END) AS 'HACİZ TARİHİ'
FROM YAZ..MARDATA.BIR_TAHSIL A, YAZ..MARDATA.S_TEKLIF B, AVUKAT D
WHERE A.TEKLIF_NO1 = B.TEKLIF_NO1
AND A.TEKLIF_NO2 = B.TEKLIF_NO2
AND B.HESAP_NO = D.HESAP
AND A.HESAP_NO = D.HESAP ";
if (txtBoxText1 != "")
{
strQuery = strQuery + " AND A.ISL_TAR >= @S_TARIH_B";
dt_stb = DateTime.Parse(txtBoxText1);
myCommand.Parameters.AddWithValue("@S_TARIH_B", dt_stb);
}
if (txtBoxText2 != "")
{
strQuery = strQuery + " AND A.ISL_TAR <= @S_TARIH_S";
dt_sts = DateTime.Parse(txtBoxText2);
myCommand.Parameters.AddWithValue("@S_TARIH_S", dt_sts);
}
strQuery = strQuery + " GROUP BY B.HESAP_NO, A.TEKLIF_NO1 + '/' + A.TEKLIF_NO2,A.ISL_TAR,B.DOVIZ_KOD ,B.MUS_K_ISIM, D.AVUKAT, D.HESAP";
And this is my Function;
ALTER FUNCTION [dbo].[fngcodeme]
(
@HESAP INT,@BAS DATE, @BIT DATE,@DOV INT
)
RETURNS FLOAT
AS
BEGIN
RETURN(
SELECT SUM(TUTAR)
FROM YAZ..MARDATA.M_GHAREKET
WHERE TEMEL_HESAP = @HESAP
AND DOVIZ_KOD = @DOV
AND REF_KOD = 'GC'
AND BACAK_GRUP = 'PERT'
AND ISL_KOD = 1
AND ISL_TAR >= @BAS
AND ISL_TAR <= @BIT
)
END

What I want getting a value in this code with this function. @BAS is Start Date, @BIT is End Date How can I associate @BAS with Textbox1 and @BIT with Textbox2 ?

View 2 Replies


Similar Messages:

SQL Reporting :: Using Parameters To Search Dates In Services

Sep 19, 2010

I have recently started using SQL Server Reporting services. I currently have a problem. I am trying to achieve a search by dates in a report. I have a table with the fields RequestDate in e.g. 22-Jan-2010 or 23-Sep-2010. I have created a report in Query Designer with two parameters in it RequestDate & RequestDate2.

The Operators are for RequestDate is: Is more than or equal to The value is: 1-Jan-2010 And the Operator for RequestDate2 is: Is less than or equal to. The value is 30-Dec-2010 When i go to the SQL Statement this is produced:

SELECT
MHRA.ImportRequestID
,MHRA.UniqueID
,MHRA.CreatedBy
,MHRA.RequestDate
FROM
MHRA
WHERE
MHRA.RequestDate >= @RequestDate
AND MHRA.RequestDate <= @RequestDate2

When i go to view report i want to be able to search for dates between the dates 1 Jan 2010 and 30-Aug-2010 My query seems to pick up all or most of the results between these dates. How can i build this query so i can get specific results. For example...in the Request Date Parameter box i would put 2-feb-2010 and in Request Date 2 i would put in 5-Jun-2010 and this would return all the results between these dates.

View 1 Replies

SQL Server :: Pivot Query / Unable To Pass Dates As Parameters To Storeprocedure?

Oct 4, 2010

I am using following pivot query but not getting result as single row getting as 4 rows.

One more problem i am unable to pass dates as parameters to storeprocedure something like this

select [@date] .

SELECT 'Forecasted' AS HeadCount,
[8/1/2010], [8/8/2010], [8/15/2010], [8/22/2010]
FROM
(SELECT *
FROM TblEmpCount) AS SourceTable
PIVOT
(
SUM(EmpCount)
FOR StartDate IN ([8/1/2010], [8/8/2010], [8/15/2010], [8/22/2010])
) AS PivotTable;

I am getting result as 4 rows but i want result in single row like this

HeadCount 8/1/2010 8/8/2010 8/15/2010 8/222/2010

Forecasted 191 182 176 169

View 2 Replies

Find Difference Between Two Dates By Function?

Aug 23, 2010

I need a function written in vb to find the exact month difference between two dates.

For example
Start Date : 01/01/2010
End Date : 15/02/2010

then the difference value should be like this 1.5 i.e i need the difference in decimal value.

View 3 Replies

JQuery :: Add Parameters To This Function?

Mar 3, 2011

This is my first foray into jquery. I wrote a function that will wrap four sides and four corners around a div, effectively placing a border around a box. I would like to pass in height, width, and a third parameter to indicate hoe much padding that particular box should get. How can I do this?

<script type="text/javascript" src="/Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".smallBox").wrap("<div class='sbox-top'>" +
"<div class='sbox-bottom'>" +
"<div class='sbox-left'>" +
"<div class='sbox-right'>" +
"<div class='sbox-tl'>" +
"<div class='sbox-tr'>" +
"<div class='sbox-bl'>" +
"<div class='sbox-br' style='padding:5px 5px;'>" +
"<div style='background-color: #f2f0f1;padding:0 5px;'>" +
"</div></div></div></div></div></div></div></div>");
});
</script>

View 4 Replies

Return Parameters From Function

Mar 28, 2011

internal static void GetUserData(int userId, out string userName,
out string userEmail, out string userPassword)
{
using (SqlConnection con = Util.GetConnection())
{
con.Open();
using (SqlCommand cmd = new SqlCommand("usp_UD_SelectById", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@UD_ID", SqlDbType.Int).Value = userId;
cmd.Parameters.Add("@UD_UserName", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@UD_Password", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@UD_Email", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
userName = Convert.ToString(cmd.Parameters["@UD_UserName"].Value);
userEmail = Convert.ToString(cmd.Parameters["@UD_Email"].Value);
userPassword = Convert.ToString(cmd.Parameters["@UD_Password"].Value);
}
}
}

and the call

string userEmail;
string userName;
string userPassword;
MemberHelper.GetUserData(userId, out userName, out userEmail, out userPassword);

Sometimes I need to get just one parameter from the out parameters, how can I call the function when I want to get just one:

string userPassword;
MemberHelper.GetUserData(userId,"","",out userPassword);

View 1 Replies

How To Access Args Parameters In Function

Oct 25, 2010

I want to set ASP.net custom validator error parameter text through client side javascript. How can access it via sender, args parameters in my function?

View 1 Replies

Javascript - Callback Function With Parameters

Jan 4, 2011

I'm using AJAX Page Methods, but I can't seem to be able to pass the needed parameters:

function getFavStatus() {
//favs is a list of DOM <imgs> that I want to modify their img.src attribute
for (i = 0; i < favs.length; i++) {
PageMethods.isFavorite(favs[i].alt,setFavImg(favs[i]));
}
}
function setFavImg(fav, response) {
fav.src = response;
}
The problem that I can't figure out is how to use the "response" from PageMethods, AND pass the DOM object to the callback function.
I've also tried doing something like this:
function getFavStatus() {
for (i = 0; i < favs.length; i++) {
PageMethods.isFavorite(favs[i].alt, function (response) {
favs[i].src = response;});
);
}
}

In this case, the response works properly, but i is always > favs.length, because it has already iterated through the loop... Edit: My PageMethods.isFavorite signature is: [System.Web.Services.WebMethod] public static string isFavorite ( string p_id )

View 3 Replies

Looking For A Function That Takes Two String Parameters?

Aug 20, 2010

i am looking for a function that takes two string parameters

str1 = "hello how are you today mr john"
str2 = "how today"

and in return it shoud highlight the words "how" and "today".

View 2 Replies

Call SQL Function With Multiple Parameters From C# Web Page?

Mar 30, 2010

I have an MS SQL function that is called with the following syntax: SELECT Field1, COUNT(*) AS RecordCount FROM GetDecileTable('WHERE ClientID = 7 AND LocationName = ''Default'' ', 10) The first parameter passes a specific WHERE clause that is used by the function for one of the internal queries. When I call this function in the front-end C# page, I need to send parameter values for the individual fields inside of the WHERE clause (in this example, both the ClientID & LocationName fields) The current C# code looks like this:

String SQLText = "SELECT Field1, COUNT(*) AS RecordCount FROM GetDecileTable('WHERE
ClientID = @ClientID AND LocationName = @LocationName ',10)";
SqlCommand Cmd = new SqlCommand(SQLText, SqlConnection);
Cmd.Parameters.Add("@ClientID", SqlDbType.Int).Value = 7; // Insert real ClientID
Cmd.Parameters.Add("@LocationName", SqlDbType.NVarChar(20)).Value = "Default";
// Real code uses Location Name from user input
SqlDataReader reader = Cmd.ExecuteReader();

When I do this, I get the following code from SQL profiler:

exec sp_executesql N'SELECT Field1, COUNT(*) as RecordCount FROM GetDecileTable
(''WHERE ClientID = @ClientID AND LocationName = @LocationName '',10)',
N'@ClientID int,@LocationID nvarchar(20)',
@ClientID=7,@LocationName=N'Default'

When this executes, SQL throws an error that it cannot parse past the first mention of @ClientID stating that the Scalar Variable @ClientID must be defined. If I modify the code to declare the variables first (see below), then I receive an error at the second mention of @ClientID that the variable already exists.

exec sp_executesql N'DECLARE @ClientID int; DECLARE @LocationName nvarchar(20);
SELECT Field1, COUNT(*) as RecordCount FROM GetDecileTable
(''WHERE ClientID = @ClientID AND LocationName = @LocationName '',10)',
N'@ClientID int,@LocationName nvarchar(20)',
@ClientID=7,@LocationName=N'Default'

I know that this method of adding parameters and calling SQL code from C# works well when I am selecting data from tables, but I am not sure how to embed parameters inside of the ' quote marks for the embedded WHERE clause being passed to the function.

View 1 Replies

Web Forms :: Passing Multiple Parameters To VB.net Function

Jan 7, 2010

Im wonding what the correct syntax is to pass 2 parameters from a Ascx control into a Vb.net function? Heres what I currently have:

<asp:Literal
ID="CommentFooterLiteral1"
Visible='<%# Eval("Approved") Or IsModerator() %>'
Text='<%# FormatFooter(Eval("Anonymous"), Eval("DisplayName"), Eval("CreatedDate")) &#43; "
" &#43; GetModeratorStatus(Eval("UserId")) %>'
runat="server"
/>

The Function "FormatFooter", needs to pass in Anonymous and DisplayName parameters. Anyone know the correct syntax for doing this?

View 2 Replies

Access Values Of Parameters Passed To A Function?

Jan 13, 2010

In my application if I get an exception I catch it and send stackTrace through email. I also need the values of parameters passed to this function. I can get the names of function and parameters using MethodBase class of System.Reflection.

View 7 Replies

AJAX :: Send Parameters To The Callback Function?

Aug 27, 2010

I need to send som parameters to the callback function of my AJAX call, how can i do that: ex.

[Code]....

View 8 Replies

Send 2 Parameters From Code-behind (c#) To A Javascript Function?

May 26, 2010

I am wanting to send 2 parameters from my code-behind (c#) to a javascript function located in the header of the .aspx site.

View 4 Replies

Javascript - Ajax Call Pass Parameters To Function?

Feb 7, 2011

What is wrong with this code? I am trying to pass parameters to a WCF function. I couldn't get this to work. I am getting Ajax error.

$.ajax({
url: applicationPath + "/Test.svc/GetData",
type: "POST",
dataType: "json",
data: '{GId":' + sender.get_value() + '"GName":' + sender.get_text() + '"mId":' + testId + '}',
contentType: "application/json; charset=utf-8",
success: function(result)
{
//trying to fill combobox here
},
});

View 1 Replies

C# - Dynamic Return Type Based On The Input - Create A Function Which Would Have Two Parameters

Feb 14, 2011

I want to create a function which would have two parameters

public **XYZ** GetOputput(string strToConvert, **ABC**)

What I want from this function, that I will send a string to this function and the datatype in which I want to convert this string [Ex: Int32,Int64, datetime etc..] and the return will be the same as the datatype I have sent as the input parameter.

I want to have something like this in my function:

[code]....

View 5 Replies

Want Dates Selected Are In Between Textbox2 Dates And Textbox3 Dates Then Textbox1.text="sumit" Else Textbox1.text="No Dates"?

Dec 4, 2010

If i have three textboxes in my vb.net webform.

Textbox1.text="Sumit"

Textbox2.text="4-Dec-2010"

Textbox3.text="1-Jan-2011"

I want if dates selected are in between textbox2 dates and textbox3 dates then textbox1.text="sumit" else textbox1.text="No dates"

View 1 Replies

Web Forms :: Way To Get All The Dates That User Click Onthe Calendar ( Note The Dates Doesn't Get)

Nov 4, 2010

I need some pointers to start on this.We are building a time off application where three instances of a calendar control will be displayed ( prev - current and next month) now users can click on various dates accross all three instances and then a count of number of days should be diaplyed in the parent textbox.

To begin with this, i started with adding the dates clicked by the user in Calendar2_SelectionChanged method into a list<> so that i can get the all dates user clicked and then add it to calander's selected dates collection. But this throws an e" object reference not set" error.

Is there anyother way to get all the dates that user click onthe calendar( note the dates doesn't get highlighed so seleteddates doesnt work)does anyone has a good example for this.

View 2 Replies

Architecture :: Need A Function Or Store Procedure Which Returns Only Locations Near By 10kms Of Given Longitude/latitude Parameters?

Feb 26, 2010

I have many locations stored with addresses and longitude/latitude information in my database.I need a function or store procedure which returns only locations near by 10kms of given longitude/latitude parameters.It is not neccesary to be a sql query but I am fine with any other solution.

View 6 Replies

AJAX :: Calendar Extender - Show Only Dates Of Current Month Not Previous Dates When User Clicks On Button

Sep 22, 2010

i want to use a ajax calender extender in which when user clixcks on button caleder show only dates of current month not previous dates.i dont want to disable dates. i should not apper on current month calender. means it should start from 1 and end to 30 or 31

View 3 Replies

Web Forms :: Selected Dates From DB Become Deselected When Try To Select New Dates?

Jan 13, 2011

once a user select an item from dropdownlist > Dates from DB are shown on calendar in pink color.

The problem now is when i want to select new dates the selected dates(in pink) become deselected .. I want them to stay selected so i can know which dates are already used .

[Code]....

View 5 Replies

DataSource Controls :: Function To Accept Unlimited Parameters For Stored Procedure - Determine Data Type

Jun 22, 2010

I am trying to write a function that can be called to run a stored procedure. I pass the stored procedure name, followed by as many parameters as I need to run the procedure. I am able to do this by using the params keyword, so my function looks something like this;

[Code]....

How can I determine what the data type of the parameter is? Maybe I need to alter the string[] part, above?

View 5 Replies

Web Forms :: How To Find Dates Of Monday Between Two Dates

Jan 21, 2010

i have to date say in MM/DD/YYYY format "1/1/2010" and 1/30/2010". now i want to find dates which comes on monday. so out out will be 01/04/2010, 1/11/2010, 01/18/2010, 01/25/2010

View 2 Replies

C# - Create An Array Or List Of All Dates Between Two Dates?

Sep 17, 2010

I am generating multi-series graphs with the date along the X-Axis. The problem is that not all of the series in the graph have the same dates in the date range. Meaning that if I choose 1 Feb through 30 Apr that one series may have data that starts at 1 Feb but only goes through the end of March but another series may have data for the entire date range. This skews the charts I need to create. Go, given the date range taken at the begining of the query I'd like to generate a list of dates and populate the data to be graphed, padding those series with 0's for those dates that have no data.

View 3 Replies

Forms Data Controls :: Display Dates As Header For Datalist Control (dynamic Dates) And Header In Each Row

Sep 30, 2010

How to display dynamic header for datalist control(Dates are dynamic).Also i want header in each row.I want something like this.Words in bold are headers.Header also in each

row.8/1/2010,8/8/2010,8/15/2010,8/22/2010 are dynamic dates whic change every month based on user selecting date from datecontrol.

HeadCount 8/1/2010 8/8/2010 8/15/2010 8/22/2010
Forecaster HC 447 446 441 432
Agents Scheduled 447 446 441 432

View 1 Replies







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