473,406 Members | 2,549 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,406 software developers and data experts.

System.FormatException: 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.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(IForm atProvider
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 <>
in InstallationDate 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 ShowAccessTableStructure()

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=Microsoft.Jet.OLEDB.4.0; Data
Source=D:\Intranet\Data\Intranet.mdb")

Dim objConn2 As OleDbConnection = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=D:\Intranet\Data\Intranet.mdb")

objConn.Open()

objConn2.Open()

objDT1 =
objConn.GetOleDbSchemaTable(System.Data.OleDb.OleD bSchemaGuid.Tables, New
Object() {Nothing, Nothing, Nothing, Nothing})

For i = 0 To objDT1.Rows.Count - 1

DisplayArea.Text += "<table border=0 cellpadding=0 cellspacing=0><tr><td
bgcolor='#000000'><table border=0 cellpadding=3 cellspacing=1>"

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

DisplayArea.Text += "<tr bgcolor='#ddeeaa'><td><b>" & strTablename &
"</b></td></tr>"

Dim objDA2 As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM [" &
strTablename & "]", objConn2)
objDA2.Fill(objDS, "DBRows")
For Each dc In objDS.Tables("DBRows").Columns

cn = dc.ColumnName

DisplayArea.Text += "<tr bgcolor='#ffffff'><td>" & cn & "</td></tr>"

Next

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

Next

objConn2.Close()

objConn.Close()

End Sub


Nov 19 '05 #1
0 4837

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

Similar topics

9
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...
14
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...
3
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=' <%#...
6
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...
1
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 ...
10
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...
4
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...
4
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...
3
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'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.