|
|
Hello,
I want to find record from table where given date is matching with given date
i did as follwes but it given me error as
Error : Syntax error: Missing operand after 'Date' operator.
Code :
for (int CountHoliday = 0; CountHoliday < 3; CountHoliday++)
{
string sqlFilter = "Holiday Date = '#" + Convert.ToDateTime(Al[CountHoliday]).ToShortDateString() + "#'";
DataRow[] dtRow = dsHoliday.Tables[0].Select(sqlFilter);
if (dtRow[0].ItemArray[4].ToString() != "")
{
iCounter++;
}
}
|
|
|
|
|
Got Answer
Here it is :
string sqlFilter = "HolidayDate = '" + Convert.ToDateTime(Al[CountHoliday]).ToShortDateString() + "'";
|
|
|
|
|
I would rather have employed LINQ to DataSet to filter those...
Using
dt.AsEnumerable()
|
|
|
|
|
Hi,
I am doing this thing using the method:
<br />
for (int CountHoliday = 0; CountHoliday < 3; CountHoliday++)<br />
{<br />
string sqlFilter = "Holiday Day = '" + Convert.ToDateTime(Al[CountHoliday]).Day + "' and Holiday Month='" + Convert.ToDateTime(Al[CountHoliday]).Month + "' and Holiday Year='" + Convert.ToDateTime(Al[CountHoliday]).Year + "'";<br />
DataRow[] dtRow = dsHoliday.Tables[0].Select(sqlFilter);<br />
if (dtRow[0].ItemArray[4].ToString() != "")<br />
{<br />
iCounter++;<br />
}<br />
}<br />
<br />
You have to get the Day, Month and Year in the DataTable as columns and use the filter in that. If you will be using the full datetime value for comparison it would not help you as it throws the error in some cases. Also try to name the columns without space like "Holiday Day" or "Holiday Date" should be "HolidayDay" or "HolidayDate" or you can use Underscore in place of Space. <br />
<br />
Regards,
Kaushal Arora
|
|
|
|
|
Hi Mugdha_Aditya,
DataRow[] dtRow = dsHoliday.Tables[0].Select("Holiday Date = '"
+ Convert.ToDateTime(Al[CountHoliday]).ToShortDateString()
+ "'");
Thanks & Regards,
Jeneesh k. v.
|
|
|
|
|
In my webapplication, there is an email functionality which send email to users. The email contains a link, on clicking the link it will redirect to the application.
Since the user needs to login before redirecting the required page, first the login page displays. My requirement is, if the login is sucessful, then the user should be redirected to the specified page.
For eg: If the email link has the url, "http://test1.abc.com/DocumentAnalysis.aspx?Id=17BB87F6-F746-41C4-BE10-3CF0B050970F", while clicking on this link, the url appears as follows in the browser:
"http://test1.abc.com/login.aspx?redirect=%2fDocumentAnalysis.aspx%3fId%3d17BB87F6-F746-41C4-BE10-3CF0B050970F".
Now,if the login successful, I need to redirect the user to DocumentAnalaysis.aspx page. I may get the url through the Request.Url.AbsoluteUri path. But is there any other best way to achieve this?
Please help. Sorry for long post.
Thanks,
meeram395.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
I think this is fine. I have used this technique to keep the redirect url in the querystring and it worked perfectly.
Why are you looking for any other solution?
|
|
|
|
|
Thanks Abhishek. I was just checking out whether there are any other options through which to achieve the same.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
I think You are using for User Approval..!If thts the case Use the below..!
If You are using Forms Authentication..!
You can use of Guid Key..!
Guid UserID = new Guid(Membership.GetUser(User.Identity.Name)).ProviderUserKey.ToString());
Guid key = new Guid(Request.QueryString["id"].ToString());
MembershipUser user = Membership.GetUser(key);
user.IsApproved = true;
Membership.UpdateUser(user);
That is one Way..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Thanks. I am not using User Approval. However, it is good information. I can use it for next time.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Hi
I am not able encypt web.confige file. I am able to Create a custom RSA key container by running command
C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pc “MyKeys” -exp
after Specify a protected data provider in web.config file
and running on following command to encypt the web.config file it gives the list of all command related to ASP .NET registration options and my web.config file is not encrypted
C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "SensitiveAccountInfo" "path" -prov “MyProvider”
Please Help me in it.
Thanking You!.
Rock Star
|
|
|
|
|
|
Thanx
I got the solution I juast forgot to set the read permission on provider
Rock Star
|
|
|
|
|
hi,
you can follow the steps as below:
step1: Make sure These are not encrypted,such as
<processmodel>
<runtime>
<mscorlib>
<startup>
<system.runtime.remoting>
<configprotecteddata>
<satelliteassemblies>
<cryptographysettings>
<cryptonamemapping>
<cryptoclasses>
Step 2, Create a RSA key container,
you can use the command :aspnet_regiis -pc "ABeenKeys"–exp
Step 3, Modify web.config to identify the key container
Step 4 , Encrypt the <connectionstrings> section of your web.config file
> aspnet_regiis -pe "connectionStrings" -app "/connectionTest"
modified 27-May-14 5:05am.
|
|
|
|
|
hi all,
in my web application i made a session (Session["UserName"] = tbUserName.text) so it saves value in it if username is correct and redirect the user to mainpage.aspx.
the problem is:-
in login page if i copy the link of main page and paste it in address bar
at the login page it redirects it without even entering any data at Username and password.
i tried to check the session in main.aspx and see if empty redirect user to login which works the first time but as soon as i enter valid username and password in login the problem appear again even when i put the following at logout linkbutton (session["UserName"] = null)
can anyone help!!!!
thx in advance
|
|
|
|
|
loading from cache,clear the cache
add this on page load of all pages
Response.AddHeader("Cache-control", "no-store, must-revalidate, private,no-cache");
Response.AddHeader("Pragma", "no-cache");
Response.AddHeader("Expires", "0");
|
|
|
|
|
|
Ideally, you should destroy Session by calling Session.Abandon() method on logout.
|
|
|
|
|
tried but still the samething.....
|
|
|
|
|
Check Session Value on Page_Load. Check my Answer
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Then the problem could be with Cache. Did you tried the above solution?
|
|
|
|
|
During Logoff you should use Session.Abandon() to set all session variable to null
and In Page_Load you should check like this
if(Session["UserName"] ==null )<br />
Response.Redirect("Login.aspx");
If you need to learn more about session, please read this article
Exploring Session in ASP.Net[^]
Let me know if you need more help
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
dear Abhijit Jana,
i did what u wrote in fact my code is exactly the same..... but no use.
|
|
|
|
|
That means Session value is not null.
See what is the value of Session.
|
|
|
|