Access Date/Time value

hi, i'm a new user of asp.net. my post may have the same title as others, but i still can't find the solution to my problem. 
ok here's my problem. i have a dropdownlist, where user's can select the time from. example of my list: text = 8:00, value = 8
in the database, the field 'time' has been set to date/time datatype.
 this is my coding:
        dsSchedule.Schedule.Clear()
        daSchedule.Fill(dsSchedule)

        Dim dr As DataRow = dsSchedule.Tables(0).NewRow()
      
        dr("Title") = txttitle.Text
        dr("Date") = Calendar1.SelectedDate
        dr("Schedule") = txtschedule.Text
        dr("Time") = ddl1.SelectedValue
        dr("Username") = Session("UserName").ToString()
        dsSchedule.Tables(0).Rows.Add(dr)
        daSchedule.Update(dsSchedule)

        txttitle.Text = ""
        txtschedule.Text = ""
        lbladd.Visible = True
        lbladd.Text = "Appointment succesfully added!"

     End Sub
but whenever i try to insert into the database, i get this error :

Server Error in '/AMFinal' Application.

System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider) at System.Convert.ToDateTime(String value, IFormatProvider provider) at System.String.System.IConvertible.ToDateTime(IFormatProvider provider) at System.Convert.ToDateTime(Object value) at System.Data.Common.DateTimeStorage.Set(Int32 record, Object value) at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <16> in Time Column. Expected type is DateTime.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider) at System.Convert.ToDateTime(String value, IFormatProvider provider) at System.String.System.IConvertible.ToDateTime(IFormatProvider provider) at System.Convert.ToDateTime(Object value) at System.Data.Common.DateTimeStorage.Set(Int32 record, Object value) at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <16> in Time Column. Expected type is DateTime.

Source Error:

Line 111:        dr("Date") = Calendar1.SelectedDate
Line 112: dr("Schedule") = txtschedule.Text
Line 113: dr("Time") = ddl1.SelectedValue
Line 114: dr("Username") = Session("UserName").ToString()
Line 115: dsSchedule.Tables(0).Rows.Add(dr)

Source File: C:\Inetpub\wwwroot\AMFinal\AddTask.aspx.vb    Line: 113

Stack Trace:

[ArgumentException: System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles)
at System.DateTime.Parse(String s, IFormatProvider provider)
at System.Convert.ToDateTime(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDateTime(IFormatProvider provider)
at System.Convert.ToDateTime(Object value)
at System.Data.Common.DateTimeStorage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <16> in Time Column. Expected type is DateTime.]
System.Data.DataColumn.set_Item(Int32 record, Object value)
System.Data.DataRow.set_Item(DataColumn column, Object value)
System.Data.DataRow.set_Item(String columnName, Object value)
AMFinal.AddTask.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\AMFinal\AddTask.aspx.vb:113
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()

is my coding wrong? please help me! thanks!
0
hot_choc
3/30/2005 8:22:40 PM
asp.net.access-datasource 4679 articles. 0 followers. Follow

4 Replies
680 Views

Similar Articles

[PageSpeed] 2

You say:

text = 8:00, value = 8

However, the value "8" is not a valid date/time value.  Try using .SelectedText and see if that helps.


Starting with ASP.NET 2.0? Look at:
Programming Microsoft Web Forms
My Blog
0
douglas
4/2/2005 1:15:38 AM
although i change the value to 8:00, it won't be saved into the
database. instead of time 8:00 it shows the date (4/2/2995). there's no
..SelectedText 
0
hot_choc
4/2/2005 3:11:14 PM

Try:

dr("Time") = DateTime.Parse(ddl1.SelectedItem.Text)

 


Starting with ASP.NET 2.0? Look at:
Programming Microsoft Web Forms
My Blog
0
douglas
4/2/2005 4:46:51 PM
thanks for the suggestion but it still doesn't work. shows the date instead of time. any other suggestions?
0
hot_choc
4/2/2005 8:02:34 PM
Reply:

Similar Artilces:

DBI, MS Access, inserting/updating a Access Date/Time value
Hi, Does anyone have any idea what is up with Microsoft Access and its ridiculous Date/Time formatting options? It doesn't seem to matter what format I attempt to insert with. The directory and db file permissions are all Full Control. I'm using the "#" around the Date/Time format as required. The database has nothing as the Format in Design view on the General tab. The insert below has never worked once. On the up side if I run an insert that has no mention of the Date/Time field then it will just insert the record using the =Now() function as the default va...

How to remove the date part of a Date/Time value in MS Access
I am inserting a time value into a MS Access Date/Time field and notice that MS Access does not display the date portion of the value but when I look at the same data in my programming using a TADOTable component I am seeing the date of 12/30/1899 in conjunction with my time value. I read that Access is handling this within MS Access so that when a 0.sometime value is inserted it does not display the date. How do I handle this within my Delphi program so that I can display the time only in a Date/Time type field? Jeff Howard wrote: > I am inserting a time value into a MS Access Date/T...

Accessing Date and Time Values
Hi there. I would like to display date and time on my web application. Each label shows one info: lblMonth ---> displays current Month (e.g. Jan,Feb,Mar and so on) lblDayNo ---> displays current DayNo (e.g. 1,2,3 and so on) lblDay ---> displays current Day (e.g. Monday,Tuesday and so on) lblTime ---> displays current Time where the time is updated every minutes My code goes like this: Dim strMonth As New Date() Dim strDayNo As New Date() Dim strDay As New Date() Dim strtime As New DateTime() lblMonth.Text = strMonth.Month.ToString lblDayNo.T...

accessing access
------=_NextPart_000_029B_01C29063.1E2098D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi! I am trying to access an access mdb file for the first time. I get the following error: Can't connect(dbi::ODBC:pfawtbls.mdb ), no database driver specified and DBI_DSN env var not set at jfa_data.pl line 147 for the code: my $dbh = DBI->connect( "dbi::ODBC:pfawtbls.mdb", "", "", ) or die "Unable to connect: ". $DBI::errstr. "<br>"; What am I missing? Thanks, Jer...

Access access
========== Hi, Everyone ... I'm going to lock this thread for now. If you have a question about working with Access in Web Matrix, please start a new thread in this forum. Otherwise, this thread will get to be unwieldy. Thanks! ========== Updated 6/29/03 Hello, everyone. I've been working with the new version of Web Matrix (version .6, build 812, available right now!). In particular, I've been playing with support for Microsoft Access, which is one of the great new features in the new release. I wrote up some notes on what I've found to share some of my experiences and to a...

accessing MS Access from .net
hi I am accessing ms access data base which has a table called customers. when i try to insert data into the table i am gettign the error like "Operation must use an updatable query" and the line its showing is myOleDbcommand.ExecuteNonQuery() here is my code in page lode event Sub Page_Load(Sender As Object, E As EventArgs) Dim StrConnectString as String Dim strStatement as String strConnectSTring = "Provider=Microsoft.Jet.OLEDB.4.0;Password='';User ID=Admin;Data Source=C:\Inetpub\wwwroot\Srinu\WebApplication2\...

Retrieve Only Date from Date/Time in Ms Access
Hello,When retrieving data from an ACCESS database table, I want the generated ASP page to display only the date inputted by the user. It currently displays the date and then the time is always 12:00. Anyone have any suggestions as how I can have it display only the time, but leave the access format as Date/Time? Format the output - use {0:d} Something like:label1.text=String.Format("{0:d}",YourDate)David WierMCP/ASPInsiderASPNet101.com - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Control Grouper - easily control properties for multipl...

Inserting Date into Access Date/Time Field
Everytime i capture a date from an asp:dropdownlist and try to insert it into an access date/time field i keep getting a Data type mismatch in criteria expression error (0x80040e07). is there a way i need to format the data before inserting? Any help would be ace!1 using System; 2 using System.Data; 3 using System.Data.OleDb; 4 using System.Configuration; 5 using System.Web; 6 using System.Web.Security; 7 using System.Web.UI; 8 using System.Web.UI.WebControls; 9 using System.Web.UI.WebControls.WebParts; 10 using System.Web.UI.HtmlControls; 11 12 ...

Access to a field from my Access DataSource in my DetailsView
I am creating an Audit Trail of changes made to my table using a DetailsView RowUpadated event. This field,  CustomerName, in the table is not being updated so I can not grab the data from my  DictionaryEntry  old or new values statements as I am doing for my audit trail. However, it is in my select statement for the DetailsView from my AccessDataSource. I can’t seem to find a reference where I can get the value of a field from my AccessDataSource. How can I reference it ?  Thx.           <asp:DetailsView ID="DetailsView1" ...

Exporting local access values to my online access values automatically at regular int ?
I am having Access database in my local system . Values in the access database will be updated for every 5 min . I am also having Access database online with the same structure database of Access in my local system . What i want is my Access database values must be updated in my online Access database at every 5 min automatically . How to do that ? To sync to databases you can use a light replication, as its access. Write a Windows service that copies every 5 minutes the new data. Now what happens when the online database gets updated? or its read only?CheersAlMy BlogMapStats....

accessing linked Access table from .net
We have an access database with a linked table to MYOB through ODBC. The MYOB table appears in access with a green dot indicating it's a linked table. In Access it all works fine. When we try to get at it through .net, it brings up DB_SEC_E_AUTH_FAILED(0x80040E4D) which as far as I can see indicates authentication failed. Any idea what is required to be able to use it from.Net? You might try this stepp0, put in admin for the username and leave the password blank (unless you specified other) Source=C:\Inetpub\wwwroot\Components\Databases\Db.m...

date time in Access
I'm having trouble with date time in Access with DBI/ODBC I'm trying to do this: SELECT * FROM some_table WHERE date_time_field > 11/30/99 That's giving me all dates, where: SELECT * FROM some_table WHERE date_time_field < 11/30/99 Is giving me none. I must have done something completely wrong! It really is a date time field and looks like this: 1998-06-25 00:00:00 Jeff Hi Jeff, the correct syntax in access itself would be: >#9/30/1999# the writing of the data (mm.dd or dd.mm or mm/dd) belongs to the system variables set on the system ace...

superreview granted: [Bug 301391] Include some child values in concatenated accessible names : [Attachment 189854] Other than for items whose values are a URL, use accessible values when concatening
Boris Zbarsky <bzbarsky@mit.edu> has granted Aaron Leventhal <aaronleventhal@moonset.net>'s request for superreview: Bug 301391: Include some child values in concatenated accessible names https://bugzilla.mozilla.org/show_bug.cgi?id=301391 Attachment 189854: Other than for items whose values are a URL, use accessible values when concatening an accessible name https://bugzilla.mozilla.org/attachment.cgi?id=189854&action=edit ...

superreview requested: [Bug 301391] Include some child values in concatenated accessible names : [Attachment 189854] Other than for items whose values are a URL, use accessible values when concatenin
Aaron Leventhal <aaronleventhal@moonset.net> has asked Boris Zbarsky <bzbarsky@mit.edu> for superreview: Bug 301391: Include some child values in concatenated accessible names https://bugzilla.mozilla.org/show_bug.cgi?id=301391 Attachment 189854: Other than for items whose values are a URL, use accessible values when concatening an accessible name https://bugzilla.mozilla.org/attachment.cgi?id=189854&action=edit ...

Web resources about - Access Date/Time value - asp.net.access-datasource

Random-access memory - Wikipedia, the free encyclopedia
Random access memory ( RAM ) is a form of computer data storage . A random access device allows stored data to be accessed in any order in very ...

Motorists can access up-to-date service station data on fuel prices - The Courier-Mail Search Search
MOTORISTS will be able to access up-to-date information on local petrol prices next year.

All-Access with Bruce Arians: Rest is for the bye week
Bruce Arians talked Monday about his team after it demolished the Packers 38-8, giving them their 13th win and keeping them alive for the NFC's ...

CMS 2017 Access standards are still soft
... a QHP issuer in a State would be required to ensure that a certain percentage of the potential enrollees residing in a county have access to ...

Widespread access problems for EA
Electronic Arts experienced log in and connection issues for many of its titles on Thursday, the video game company said.

Google Gets Access To Your Kids’ Data Because It’s A “School Official”
... with scheduling? So it wouldn’t come as a surprise to most parents that “school officials” are on the list of entities who are allowed to access ...

(Updates) PSA: Steam is giving people access to random accounts, don't log in
... According to multiple Steam users on Twitter and NeoGaf (plus a hands-on report from Kotaku ), a problem with Steam's cache gave users access ...

Access geo-restricted content for the rest of your life
Access geo-restricted content for the rest of your life

CargillVoice: How a Partnership in Côte d'Ivoire is Providing Farmers with Access to Loans
By the CargillVoice Team A project addressing access to affordable funding for cocoa farmer cooperatives in Côte d’Ivoire, in the cocoa sector, ...

Steam Bug Gives Users Access To Other People’s Accounts And Personal Information
... Fake PS4s, bootleg Pokemon games, missing paychecks, and now this. A bug in a recent software update on Steam allowed users to gain access to ...

Resources last updated: 1/4/2016 8:38:40 AM