473,320 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

the safest way of handling datetime between asp.net and ms sql

Hi there

I know that a problem of different datetime strings formatting between
asp.net and ms sql has been covered here widely, but what I couldn't
find is the 100% safe way of getting datetime values from ms sql,
processing them in asp.net and getting them back into sql without any
risk with inconsistent Culture settings etc.

My question is: wouldn't keeping the datetime variables all the time in
datetime type, without any String conversions, prevent all such
problems?

I was trying to check it but there are few obstacles when sticking to
declarative databinding:

1) session parameters

Let's say I'm keeping datetime variable in a session. Then, I want to
use it as a parameter in a datasource. But the variable in session will
be boxed to Object type, and I have no control on how datasource will
cast it - how can I prevent it from casting it to string and inserting
it into the query as a culture-unsafe string?

I think Select Parameters collection in Data Source properties might
help - after choosing session parameter I can show Advanced Properties
and change it's type (from string to datetime) - will Data Source use
this information to cast the session variable onto datetime properly?

2) dropdownlist values

I want to bind some datetime values to dropdownlist and use its
selected value as a control parameter of a data source. Does it mean,
that implicit toString conversion must happen during binding to ddl?
ddl.selectedValue has String type - does it mean, that everything bound
to ddl is converted to string - no way to prevent it? If it's true,
then how would it be done in case of datetime, which may be casted to
string in many different ways (because of formatting possibilities)?
Would standard datetime.toString() be used when populating ddl?
thanks a lot for any insight
cheers
HP

Oct 9 '06 #1
0 1418

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: kmcnet | last post by:
Hello Everyone and thanks for your help in advance. I am developing an application that utilizes a separate class library for data access to a SQL Server database. One of the tables has several...
8
by: Manish Jain | last post by:
Platform : ASP.Net/C# void SomeFunction(DateTime date) { string text = date.ToString(); //This crashes if date is null } I am using a construct similar to above. I want to check if the date...
2
by: Mullin Yu | last post by:
I create a component to write the error log as follow, but it seems sometimes locked by other processes, and pop up the I/O exception. How can we handling the concurrency issue at file level?...
8
by: jcrouse | last post by:
I am using the following code to trap errors in a sub routine: Try Executable code Catch ex As Exception Dim strInputE As String = Application.StartupPath & "\Error.txt" Dim srE As...
4
by: Tad Marshall | last post by:
Hi, I'm having limited luck getting an ApplicationException to work right in my code. This is VB.NET, VS 2003, Windows XP SP2, .NET Framework 1.1. I thought it would be convenient to take...
5
by: AAJ | last post by:
Hi Does anyone know of any good publically available set of standards for managing dates when dealing with a database server (in my case SQL Server 2000 and c# VS2005). At the moment, if I...
2
by: nightwatch77 | last post by:
Hi, does anyone know why .Net incorrectly handles time zone conversion when passing DateTime through web services? The problem is that it seems to ignore the time zone part. My time zone is CEST,...
1
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I'm writing a demo website in VB/Dot Net 2.0. The database is SQL 2000 and the design is at least partially legacy. (And this is the first real web work I've done in 2.0. All previous work was...
4
by: Cirene | last post by:
I'm designing my db for a online Scheduling web application. How do you suggest I handle reoccuring events? In my appointments table should I just add 1 record for EACH time the appointment...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.