I'd check the values you are getting out of the data set (name, telephone, email) and confirm they aren't empty strings.
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9
try creating your settings rather than using new:
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
xmlFile = XmlReader.Create("sample1.xml", settings)
See if that helps.
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9
You have altered the code I posted up from this:
XmlReaderSettings settings = new XmlReaderSettings();
to this:
XmlReaderSettings (settings = new XmlReaderSettings());
Remove the brackets around the settings and it should work.
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9
OMG, I gave you C# code for a VB.net project... Sorry about that. I only just noticed what language you were using.
Dim settings As New XmlReaderSettings()
settings.ValidationType = ValidationType.Schema
That will most likely fix your problem.
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9
What version of VS are you using? i only ask because the ProhibitDtd method is obsolete according to MSDN. There isn't any DTD declarations in your XML are there? The sample you posted up didn't include any DTD schema.
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9
OK, MSDN says you can set the ProhibitDTD property to false and pass through the settings yourself to the create() method. Also the create() method can accept nothing as the settings.
So, if you set
settings.ProhibitDtd = false
and then pass the settings into the create() method - which doesn't require a change to your code - it might work. You can read more (but not much) here:
http://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.prohibitdtd.aspx
Hope that helps, I want to know what fixes it now too:)
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9
If you go back and check your variable declaration you have email declared as a double when it should be a string.
hericles
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 9
Take a look at OpenXML - http://msdn.microsoft.com/en-us/library/ms186918.aspx
Use a stored procedure similar to this one (replace everything that looks like <<something>>):
Use <<DataBaseName>>
Go
If Exists (Select 1 From dbo.SysObjects Where ID = Object_ID(N'dbo.<<StoredProcedureName>>') And ObjectProperty(ID, N'IsProcedure') = 1)
Begin
Print 'Drop Procedure <<StoredProcedureName>>'
Drop Procedure dbo.<<StoredProcedureName>>
End
Go
Print 'Creating Procedure <<StoredProcedureName>>'
Set Quoted_Identifier Off
Set Ansi_Nulls On
Go
Create Procedure dbo.<<StoredProcedureName>>
@XMLString NText
As
Declare @iDoc Int
Exec sp_xml_preparedocument @iDoc Output, @XMLString
Insert Into <<TableName>>
(param1, param2, param3, param4)
Select param1, param2, param3, param4
From OpenXml(@iDoc, '/root/node')
With(param1 datatype,
param2 datatype,
param3 datatype,
param4 datatype)
Exec sp_xml_removedocument @iDoc
Go
Grant Exec On dbo.<<StoredProcedureName>> To <<UserName>>
Go
stbuchok
Practically a Posting Shark
876 posts since May 2011
Reputation Points: 138
Solved Threads: 124
Skill Endorsements: 2
Sorry, the 'root/node' will need to be changed to match your XML. Like I said, you'll want to read up on OpenXML for SQL in order to better understand how it works.
stbuchok
Practically a Posting Shark
876 posts since May 2011
Reputation Points: 138
Solved Threads: 124
Skill Endorsements: 2