473,320 Members | 2,029 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.

Insert null date from XML data to SQL Server

Hello,

I am trying to insert xml data to SQL Server table. Everything works fine
while the date field in xml file is not null.
Once the date is null, <appt_date></appt_date>, I get FormatException when
inserting the records into SQL Server.
The error occures on this line: DA.Update(DS, TABLE)

Here is my VB code:

Public Function InsertFromXML(ByVal TABLE As String) as boolean
'-- READ XML FILE AND CREATE DATASET
Dim DS As New DataSet
Dim XML_Source As String = "\Program Files\ChargeCapture2003\" + TABLE
+ ".xml"
Dim fs As New FileStream(XML_Source, FileMode.Open)
Dim xr As New XmlTextReader(fs)

DS = New DataSet

DS.ReadXml(xr)
xr.Close()
fs.Close()

Dim sqlstr As String="SELECT * FROM " + TABLE
'-- INSERT DATASET RECORDS TO SQL TABLE

Dim DA As New SqlCeDataAdapter(sqlstr, CONN)
Dim CMD_Builder As SqlCeCommandBuilder
Try
CMD_Builder = New SqlCeCommandBuilder(DA)
DA.Update(DS, TABLE)
Catch ex As System.Exception
MsgBox(ex.Message.ToString)
Return False
Exit Function
End Try
Return True
End Function

Here is the source xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Main>
<Appointments>
<appt_date>01/25/2003</appt_date>
<Appt_ID>11392</Appt_ID>
</Appointments>
</Main>
-------------------------------------------------
I posted the this question before on .languages.vb.data group but didn`t get
a reply.

Thanks in advance for any help,
Roman

Nov 21 '05 #1
0 1187

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

Similar topics

4
by: DTB | last post by:
I am having trouble creating an INSTEAD OF trigger in SQL Server to replicate a BEFORE UPDATE trigger from ORACLE. Here is a sample of the ORACLE BEFORE UPDATE trigger: CREATE TRIGGER myTRIGGER ON...
4
by: stefy | last post by:
I'd like insert null value from a query but i can do it, if my query is : UPDATE table:name UPDATE euro='' WHERE id='5'; i have a sybase message warning like this : Error converting data type...
2
by: schumacker | last post by:
Hi everyone! I am working with Delphi v7 and MS SQLServer. I am trying to insert data in a table with a SQL sentence. Some of the fields of my table are type char or varchar, and they can have...
10
by: Python_it | last post by:
Python 2.4 MySQL-python.exe-1.2.0.win32-py2.4.zip How can I insert a NULL value in a table (MySQL-database). I can't set a var to NULL? Or is there a other possibility? My var must be variable...
5
by: darrel | last post by:
I have the following right now to enter a date into SQL getting the data from some pull down menus: ------------------------------------------------- dim dateCCJApprovedDate as DateTime if...
6
by: Dean Slindee | last post by:
I am looking for the "right" way to handle inserting and presenting null date values. Public Const c_NullDate As Date = #12:00:00 AM# If I set the value of a date variable in an SQL Server insert...
3
by: rc | last post by:
How to insert NULL values in to int field using params. I'm trying to use pymssql.execute, passing the operation and list of params. One of the values in the params is a NULL value going to int...
1
by: billa856 | last post by:
Hi, I am trying to insert Null value in column(ShipDate) in my table.That column(ShipDate)'s type id date/time and format is short date. I am using "" to insert Null in that column(ShipDate)...
3
by: gsreenathreddy | last post by:
Hi! I would like to insert the date in specified format in DB, the date type is Date Type, I am using the following queries to insert the data 1) INSERT INTO EMP VALUES (1, 'red', 'CLERK', 2,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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.