Thursday, March 29, 2012
Date range parameters don't work in reportviewer?
security related parameters from asp.net codebehind. However, there
are two date related parameters that won't be coming from my web form,
but rather from the report form itself. When I test the report's date
parameters from visual studio it work fine, but when I attempt the
same report from a reportviewer no matter what input I place on the
report's date fields or even if I select the date picker, the report
simply resets to default and reloads. And actually the date picker
from the reportviewer does not not even pop up.
Here's my aspx code:
<%@. Page Language="VB" AutoEventWireup="false"
Inherits="_ReportViewer" MasterPageFile="~/Main/MasterPage.master"
CodeFile="~/Reports/CashSales.aspx.vb" Title="Cash Sales" %>
<%@. Register Assembly="Microsoft.ReportViewer.WebForms,
Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content1"
runat="Server">
<rsweb:ReportViewer BackColor="Transparent" ZoomMode="PageWidth"
Width="100%" ProcessingMode="Remote" ID="ReportViewer1"
runat="server">
<ServerReport ReportPath="/Retailer/CashSales"
ReportServerUrl="http://myserver/reportserver" />
</rsweb:ReportViewer>
</asp:Content>
the code behind:
Imports system.web.security.membership
Imports system.web.security.Roles
Imports Microsoft.Reporting.Webforms
Note: I'm only passing the parameters that are not coming from the
reportviewer form.
Partial Class _ReportViewer
Inherits System.Web.UI.Page
Private Users As New Retailer.Core()
Protected Overrides Sub OnLoad(ByVal e As EventArgs)
Dim Roles() As String = GetRolesForUser(Page.User.Identity.Name.ToString)
Dim cred As New Retailer.ReportServerCredentials("myuser",
"mypassword", "mydomain")
ReportViewer1.ServerReport.ReportServerCredentials = cred
Dim param As New ReportParameter("r_user",
Page.User.Identity.Name.ToString)
Dim param2 As New ReportParameter("r_role", Roles(0))
Dim p() As ReportParameter = {param, param2}
ReportViewer1.ServerReport.SetParameters(p)
ReportViewer1.ServerReport.Refresh()
End Sub
End Class
on my reportviewer form, at the top I have parameters for startdate
and end date, they are not set to internal or hidden.
thanks for any help or information.update on this. I see I am getting a javascript error, but it then
loading the report. How can I troubleshoot this? I've got disable i.e
script debugging turned off on i.e 7.0, but where would i place this
javascript to trap the error.
debugger; // execution will break here
to see the errors in VS.NET.
my report viewer in on a contentpage.
I see others have had a similar problem.
thanks for any help or information!|||More on this..
I noticed I get a javascript error when click on the calendar select:
Line: 606
Object Required
When I attempt to debug I get a Just-In-time failed : Unspecified
error. Check the documentation index for 'Just-in-time debugging,
errors' for more information.
and if I enter anything in the date fields, it disregards them and
loads with the defaults.
Could it be that I'm not sending security information when these built
in javascript functions are called?
thanks again.
Sunday, March 25, 2012
Date problem
This code below in VB.net , delete a record in the database next day from inserting it to DB, for example:
If I add new record today 14-7-2005, and tommorow 15-7-2005 open to view the records available, i will not find it this record because it was deleted.
PrivateSub checkdate()
Dim ssqlAsString
Dim start_dateAsDate
Dim updcmdAs SqlClient.SqlCommand
mysqladap =New SqlClient.SqlDataAdapter(" select start_date from auction ", mySqlConn)
If Today.Date > start_dateThen
ssql = "delete auction where start_date < '" & Today.Date & "'"
updcmd =New SqlClient.SqlCommand(ssql, mySqlConn)
updcmd.ExecuteNonQuery()
EndIf
EndSub
BUTI want to change that code in a way that the record will be deleted after 3 days from the date it was inserted, that means the period for each record to stay in the DB is 3 days and after that will be deleted , is that possible ?? if yes how can it be changed??
Regards
After this, you can delete all the records older than three days:
"DELETE FROM TABLE WHERE TSINSERT < " & Now.AddDays(-3).ToString
Another thing which you might do is to schedule a job on the database to automatically do the cleaning for you.
(but i have no experience in that so far)
Date portion comparison of a datetime field
a time portion. I give my users the option to perform an equals,
greater than, less than, or between comparison. The trouble comes in
the way the application builds the criteria string. The WHERE clause
passed in is in the format, "(start_dt = '2005/05/16 07:00:00.000')".
What I want to do is only compare the date portion of start_dt to the
date portion of the passed in time. Manipulating the start_dt with the
built-in SQL functions isn't a problem, but altering the date passed in
from the ASP.NET would be a massive framework change in the app.
Is there any way to only compare the date portions of both the SQL
field and the passed in value?
Thanks.Create a stored procedure instead creating the statement dynamically.
create procedure dbo.usp_proc1
@.sd datetime
as
set nocount on
select c1, ..., cn
from table1
where
start_dt >= convert(char(8), @.sd, 112)
and start_dt < convert(char(8), dateadd(day, 1, @.sd), 112)
return @.@.error
go
AMB
"colinhumber" wrote:
> I have a datetime variable coming from my ASP.NET application that has
> a time portion. I give my users the option to perform an equals,
> greater than, less than, or between comparison. The trouble comes in
> the way the application builds the criteria string. The WHERE clause
> passed in is in the format, "(start_dt = '2005/05/16 07:00:00.000')".
> What I want to do is only compare the date portion of start_dt to the
> date portion of the passed in time. Manipulating the start_dt with the
> built-in SQL functions isn't a problem, but altering the date passed in
> from the ASP.NET would be a massive framework change in the app.
> Is there any way to only compare the date portions of both the SQL
> field and the passed in value?
> Thanks.|||You have to convert it to a the valid format you want to comapre it to, e.g.
(from BOL --> Convert)
CONVERT(varchar(8),YourdateinHere,112) which will apply iso date formatting
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"colinhumber" <colinhumber@.discussions.microsoft.com> schrieb im Newsbeitrag
news:AE4EA0BE-51D8-459F-A071-225F6833AFAB@.microsoft.com...
>I have a datetime variable coming from my ASP.NET application that has
> a time portion. I give my users the option to perform an equals,
> greater than, less than, or between comparison. The trouble comes in
> the way the application builds the criteria string. The WHERE clause
> passed in is in the format, "(start_dt = '2005/05/16 07:00:00.000')".
> What I want to do is only compare the date portion of start_dt to the
> date portion of the passed in time. Manipulating the start_dt with the
> built-in SQL functions isn't a problem, but altering the date passed in
> from the ASP.NET would be a massive framework change in the app.
> Is there any way to only compare the date portions of both the SQL
> field and the passed in value?
> Thanks.|||You need to consider using CONVERT fnc with RIGHT
or using DATEPART !
exemple :
right(convert(varchar, @.datetime, 112),10)
or
cast(datepart(hour,@.datetime) as varchar) + ':' +
cast(datepart(minute,@.datetime) as varchar) + ':' +
cast(datepart(second,@.datetime) as varchar)|||Thanks for the quick reply.
Doing the conversion on the start_dt isn't a problem, but as the value being
passed in from the app is in a dynamic string, performing some string
manipulation would be difficult as the string length could vary. The
frameworks as it stands uses dynamic criteria strings so changing that is no
t
an option. I was hoping there was a way to compare only the date portions
without too much manipulation.
"Jens Sü?meyer" wrote:
> You have to convert it to a the valid format you want to comapre it to, e.
g.
> (from BOL --> Convert)
> CONVERT(varchar(8),YourdateinHere,112) which will apply iso date formattin
g
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "colinhumber" <colinhumber@.discussions.microsoft.com> schrieb im Newsbeitr
ag
> news:AE4EA0BE-51D8-459F-A071-225F6833AFAB@.microsoft.com...
>
>|||DateDiff(day, 0, <AnyDate> ) strips off the time portion...
so
Where DateDiff(day, 0, start_dt) <Operator> DateDiff(day, 0, @.PassedInDate)
is one way to do this generically. (Happens to be really fast too.)
"colinhumber" wrote:
> I have a datetime variable coming from my ASP.NET application that has
> a time portion. I give my users the option to perform an equals,
> greater than, less than, or between comparison. The trouble comes in
> the way the application builds the criteria string. The WHERE clause
> passed in is in the format, "(start_dt = '2005/05/16 07:00:00.000')".
> What I want to do is only compare the date portion of start_dt to the
> date portion of the passed in time. Manipulating the start_dt with the
> built-in SQL functions isn't a problem, but altering the date passed in
> from the ASP.NET would be a massive framework change in the app.
> Is there any way to only compare the date portions of both the SQL
> field and the passed in value?
> Thanks.
Wednesday, March 7, 2012
Date Format
I have a written a stored procedure and excecuting it and displaying it in gridview(ASP.NET). I am getting Birthdate in the form of8/23/1956 12:00:00 AM. I just need8/23/1956. I have defined it as smalldatetime in stored procedure. How can I get it in that format ?
HELP.......
In your .net code, if the object is of type DateTime you can call ToShortDate.
|||Either you can convert the datetime to a varchar in your stored procedure:
select convert(varchar(10), getdate(), 103)
... or you can format the output in the GridView:
<asp:BoundFieldDataField="now"DataFormatString="{0:dd/MM/yyyy}"HtmlEncode="false"/>
|||Set the DataFormatString, either in designer or HTML:
<asp:BoundField DataField="Date" DataFormatString="{0:dd-MMM-yy}" HeaderText="Date" HtmlEncode="false" />|||You can read more about CONVERT here:http://msdn2.microsoft.com/en-us/library/aa226054(SQL.80).aspx
...and more about DataFormatString here:http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx
|||Thanks a bunch ... millepag
That CONVERT thing worked for me!!!!
Date Format
the database. The date format I am using is MM/DD/YYYY but that seems to
work on my local server and not on my production server. On my production
server, I get errors if the date isnt in DD/MM/YYYY. Does anyone know why or
where there is a setting to change this? I am not sure if this is a SQL or
server issue
Sounds a little odd. For some reason your default date format sound like UK English.
Have you tried doing direct selects from the SQL sever using the MM/DD/YYYY format.
if that fails then look at sp_configure for the default full-text language. Make sure that it is 1033 for US English and not 2057 for UK English. That may not be the fix but I am still looking.
Jeff
Saturday, February 25, 2012
Date Format
the database. The date format I am using is MM/DD/YYYY but that seems to
work on my local server and not on my production server. On my production
server, I get errors if the date isnt in DD/MM/YYYY. Does anyone know why or
where there is a setting to change this? I am not sure if this is a SQL or
server issueSounds a little odd. For some reason your default date format sound like UK English
Have you tried doing direct selects from the SQL sever using the MM/DD/YYYY format
if that fails then look at sp_configure for the default full-text language. Make sure that it is 1033 for US English and not 2057 for UK English. That may not be the fix but I am still looking
Jeff
Date Format
the database. The date format I am using is MM/DD/YYYY but that seems to
work on my local server and not on my production server. On my production
server, I get errors if the date isnt in DD/MM/YYYY. Does anyone know why or
where there is a setting to change this? I am not sure if this is a SQL or
server issueSounds a little odd. For some reason your default date format sound like UK
English.
Have you tried doing direct selects from the SQL sever using the MM/DD/YYYY
format.
if that fails then look at sp_configure for the default full-text language.
Make sure that it is 1033 for US English and not 2057 for UK English. That
may not be the fix but I am still looking.
Jeff
Friday, February 24, 2012
Date Datatype
insert the date and time into a SQL database by using hour(now). I am having
a hard time trying to figure out which datatype to use in SQL to store this
value. I have tried using datetime, char, nchar, text and nothing seems to
work. Anyone have any ideas? Thanks!
Regards, :)
Christopher BowenDo you want to store the time in terms of hours only?
Madhivanan|||Christopher,
Is the datatype of the column a DateTime field and make sure the variable
storing this value (in .NET i assume) is a System.DateTime - or use
System.DateTime.Now. Using the SqlCommand Object add a parameter of type
datetime and assign this .net variable eg:
public void InsertDateTime()
{
DB Access setup....
...
using (SqlCommand command = new SqlCommand(etc...));
{
command.Connection = someConnectionPreviouslySetup;
command.CommandText = "INSERT INTO TableToInsertInto
(DateTimeField) VALUES (@.DateTimeField)";
command.CommentType = CommandType.Text;
//add the parameter to the parameters collection
command.Parameters.Add("@.DateTimeField", SqlDbType.DateTime);
//set the parameter to the required value
command.Parameters["@.DateTimeField"].Value =
System.DateTime.Now;
command.ExecuteNonQuery();
}
}
I am doing a mini sample in c# (this will NOT compile).
Regards,
Adrian.
<madhivanan2001@.gmail.com> wrote in message
news:1109141955.543915.123420@.g14g2000cwa.googlegroups.com...
> Do you want to store the time in terms of hours only?
> Madhivanan
>|||Hi
Format your value as 'YYYYMMDD' and try to insert
"Christopher Bowen" <c_bowen@.earthlink.net> wrote in message
news:%23OdiaKXGFHA.1740@.TK2MSFTNGP09.phx.gbl...
> I am using Visual Studio .NET 2003 with SQL Server 2000. I am trying to
> insert the date and time into a SQL database by using hour(now). I am
having
> a hard time trying to figure out which datatype to use in SQL to store
this
> value. I have tried using datetime, char, nchar, text and nothing seems to
> work. Anyone have any ideas? Thanks!
> Regards, :)
> Christopher Bowen
>|||I will give your examples a try and I will let you know how it turns out.
Thanks for the help!
"Christopher Bowen" <c_bowen@.earthlink.net> wrote in message
news:#OdiaKXGFHA.1740@.TK2MSFTNGP09.phx.gbl...
> I am using Visual Studio .NET 2003 with SQL Server 2000. I am trying to
> insert the date and time into a SQL database by using hour(now). I am
having
> a hard time trying to figure out which datatype to use in SQL to store
this
> value. I have tried using datetime, char, nchar, text and nothing seems to
> work. Anyone have any ideas? Thanks!
> Regards, :)
> Christopher Bowen
>|||It worked! I went into my table and changed the datatype to "datetime" and
used the code system.datetime.now. Thanks to all of you for all of your
help!
Kind Regards, :)
Christopher Bowen
"Christopher Bowen" <c_bowen@.earthlink.net> wrote in message
news:%23OdiaKXGFHA.1740@.TK2MSFTNGP09.phx.gbl...
>I am using Visual Studio .NET 2003 with SQL Server 2000. I am trying to
>insert the date and time into a SQL database by using hour(now). I am
>having a hard time trying to figure out which datatype to use in SQL to
>store this value. I have tried using datetime, char, nchar, text and
>nothing seems to work. Anyone have any ideas? Thanks!
> Regards, :)
> Christopher Bowen
>
Tuesday, February 14, 2012
DATE AND HOUR
Hello people,
I'm migrating an application from asp to asp.net and access to ms sql 2005. On the old db, there's a table with a column to store date and a column to store time. Ms sql only works with date and time together, right? I created a query to get the time from time column and update the date column inserting the time. I did something like this:
UPDATE S_ACC_MONEY
SET Date_Oper = CONVERT(varchar, Date_Oper, 101) + ' ' + CONVERT(varchar, Time_Oper, 108)
Does anyone knows a better way to do that? Any other comments?
Thanks!
you might also want to do a final conversion to datetime as in:
Date_Oper =CONVERT(datetime,CONVERT(varchar, Date_Oper, 101) + ' ' + CONVERT(varchar, Time_Oper, 108))