473,769 Members | 4,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.FormatEx ception: String was not recognized as a valid DateTime

RSH
I am having a bit of trouble filling a datatable with a query. I'm getting
the error message:

System.FormatEx ception: String was not recognized as a valid DateTime. at
System.DateTime Parse.Parse(Str ing s, DateTimeFormatI nfo 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(Stri ng value, IFormatProvider
provider) at System.String.S ystem.IConverti ble.ToDateTime( IFormatProvider
provider) at System.Convert. ToDateTime(Obje ct value) at
System.Data.Com mon.DateTimeSto rage.Set(Int32 record, Object value) at
System.Data.Dat aColumn.set_Ite m(Int32 record, Object value)Couldn't store <>
in InstallationDat e Column. Expected type is DateTime.

The problem is that the tables are arrived at dynamically and the code
cycles through the tables one by one and outputs the datatables at the end
of each. How can I have it ignore the offending information dynamically
before causing the error. If the tables were known in advance I could write
a where clause but since it is all dynamica I dont have the information to
create a where clause.

Any ideas?

Thanks,
RSH
Private Sub ShowAccessTable Structure()

Dim objDS As DataSet = New DataSet

Dim objDT1 As DataTable

Dim strDisplay As String

Dim i As Integer

Dim strTablename As String

Dim dc As DataColumn

Dim cn As String

Dim cdt As String

Dim objConn As OleDbConnection = New
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=D:\Intra net\Data\Intran et.mdb")

Dim objConn2 As OleDbConnection = New
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=D:\Intra net\Data\Intran et.mdb")

objConn.Open()

objConn2.Open()

objDT1 =
objConn.GetOleD bSchemaTable(Sy stem.Data.OleDb .OleDbSchemaGui d.Tables, New
Object() {Nothing, Nothing, Nothing, Nothing})

For i = 0 To objDT1.Rows.Cou nt - 1

DisplayArea.Tex t += "<table border=0 cellpadding=0 cellspacing=0>< tr><td
bgcolor='#00000 0'><table border=0 cellpadding=3 cellspacing=1>"

strTablename = objDT1.Rows(i). Item(2)

DisplayArea.Tex t += "<tr bgcolor='#ddeea a'><td><b>" & strTablename &
"</b></td></tr>"

Dim objDA2 As OleDbDataAdapte r = New OleDbDataAdapte r("SELECT * FROM [" &
strTablename & "]", objConn2)
objDA2.Fill(obj DS, "DBRows")
For Each dc In objDS.Tables("D BRows").Columns

cn = dc.ColumnName

DisplayArea.Tex t += "<tr bgcolor='#fffff f'><td>" & cn & "</td></tr>"

Next

DisplayArea.Tex t += "</table></td></tr></table><br>"

Next

objConn2.Close( )

objConn.Close()

End Sub


Nov 19 '05 #1
0 4897

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

Similar topics

9
4964
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
14
3689
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style of date formatting (RFC 822). I have been using a variation of RFC 1123 (just change the time zone to an offset, i.e. "-0800"). It seems to be writing okay, but it's failing to parse. I've tried changing the regional & language settings in my...
3
30664
by: Patrick Olurotimi Ige | last post by:
I moved some projects to another server and using the code below i get the error:- "String was not recognized as a valid DateTime" <asp:Label runat="server" width="40%" text=' <%# DateTime.Parse(DataBinder.Eval(Container,"DataItem.dt").ToString()).ToSh ortDateString()%>' id="Label6">
6
2503
by: Rookie Card | last post by:
I know this is a very common issue but cannot find a thread that resolves the issue. I need to re-format my dates to "MMM d, yyyy". The problem I have is I have an MSSQL database that allows <NULLS>. I'm using this code to format the dates: <%# IIF((dsCase.FieldValue("inj_beg", Container) <> nothing),DateTime.Parse(dsCase.FieldValue("inj_beg", Container)).ToString("MMM d, yyyy"), "") %>
1
4705
by: database | last post by:
I AM FACING A PROBLEM WHEN I ACCESS ONE OF THE PAGES. IT USED TO WORK BEFORE BUT AFTER RESTARTING THE APPLICATION SEVER IT GIVES THE FOLLOWING ERROR. - Server Error -------------------------------------------------------------------------------- The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.
10
4127
by: mercea | last post by:
hi all, i'm trying to insert the time/date a button was clicked on a gridview and it generates an error:the string was not recognized as a valid DateTime.There is an unknown word starting at index 0 i have changed the culture to en-US but it still doesn't work. i actually created the date/time column after some data had been entered into the table so the column allows nulls. this is my code: InsertCommand="INSERT INTO...
4
2798
by: pankajprakash | last post by:
Hi all, i have created a web application on my location (India) and when i run the application it's run fine, but when i host this application in autralia then the above errors occours by the following line DateTime WhenDtg = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")); i am not getting the solution.
4
15336
by: dhanashivam | last post by:
hi, in my web application i am getting date values from sql server database and store in the datatable. it works fine when i use the US culture. But when i change the culture to british i am getting the error. String was not recognized as a valid DateTime.Couldn't store <22/02/08> in dt1 Column. Expected type is DateTime. Any one please can help me?
3
4981
by: lucindaa | last post by:
Hi, i have a string variable having date as following format "05-01-2010" when convert this date into DateTime Format i got the following error 'String was not recognized as a valid DateTime' Please Help me to solve it
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.