Showing posts with label org. Show all posts
Showing posts with label org. Show all posts

Wednesday, March 7, 2012

Complex Schema problem

Ok, the mapping schema is as under:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ht="http://www.w3.org/1999/xhtml" xmlns:cus="http://localhost/"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
targetNamespace="http://localhost/" elementFormDefault="qualified"
attributeFormDefault="unqualified" >
<xs:element name="template">
<xs:complexType>
<xs:sequence>
<xs:element name="PatientDetails1" type="cus:FullNameBlock"
sql:relation="PatientDetails"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="FullNameBlock">
<xs:sequence>
<xs:element name="Name" type="cus:NameBlock" sql:relation="PatientName">
<xs:annotation>
<xs:appinfo>
<sql:relationship parent="PatientDetails" parent-key="PDName"
child="PatientName" child-key="ID" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="NameBlock">
<xs:sequence>
<xs:element name="FirstName" type="xs:string" sql:field="PDNFirstName" />
<xs:element name="LastName" type="xs:string" sql:field="PDNLastName" />
</xs:sequence>
<xs:attribute name="id" type="xs:ID"/>
</xs:complexType>
</xs:schema>
I am trying to xpath query the above schema using the following code:
try{
SqlXmlCommand cmd;
FileStream f;
string conString = "Provider=SQLOLEDB;Data
Source='(local)';database=TestRep; Integrated Security=SSPI";
cmd = new SqlXmlCommand(conString);
cmd.Namespaces = "xmlns:x='http://localhost/'";
cmd.CommandType = SqlXmlCommandType.XPath;
cmd.CommandText = "x:PatientDetails1";
cmd.SchemaPath = " F:\\Testing\\XML\\CustomSchema\\CustomSc
hema4.xsd";
f = new FileStream("F:\\Testing\\XML\\CustomList3.xml", FileMode.Create);
cmd.ExecuteToStream(f);
f.Close() ;
}
catch(Exception ex)
{
string temp = ex.Message;
MessageBox.Show(temp);
}
}
when I run the above mentioned code it throws the following exception:
SqlXmlException
Message="Schema: relationship expected on 'PatientDetails1'."
"Rainabba" wrote:

> Sounds like you want to look at using is-mapped="false", but you didn't gi
ve
> enough detail for me to be sure what you're doing. You can only have one
> "root" node so mapping it at all should typically throw an error unless
> you're using limit-field/limit-value to ensure you have only one row
> returning to map. If that doesn't help, be sure to reply with the exceptio
n
> and a copy of the schema throwing it.
> rainabba
> "Ahsan" <Ahsan@.discussions.microsoft.com> wrote in message
> news:9640E9E3-78A8-4CFB-8388-5377CC81A283@.microsoft.com...
> database
> schema
>Could you please try again with putting sql:is-constant='1' on the root
element (the element named as 'template' in your below schema) you don't
want to map?
Bertan ARI
This posting is provided "AS IS" with no warranties, and confers no rights.
"Ahsan" <Ahsan@.discussions.microsoft.com> wrote in message
news:A2C7C59D-5C67-4B9D-AF8B-6BF11FBA0C3B@.microsoft.com...
> Ok, the mapping schema is as under:
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:ht="http://www.w3.org/1999/xhtml" xmlns:cus="http://localhost/"
> xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
> targetNamespace="http://localhost/" elementFormDefault="qualified"
> attributeFormDefault="unqualified" >
> <xs:element name="template">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="PatientDetails1" type="cus:FullNameBlock"
> sql:relation="PatientDetails"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:complexType name="FullNameBlock">
> <xs:sequence>
> <xs:element name="Name" type="cus:NameBlock" sql:relation="PatientName">
> <xs:annotation>
> <xs:appinfo>
> <sql:relationship parent="PatientDetails" parent-key="PDName"
> child="PatientName" child-key="ID" />
> </xs:appinfo>
> </xs:annotation>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="NameBlock">
> <xs:sequence>
> <xs:element name="FirstName" type="xs:string" sql:field="PDNFirstName" />
> <xs:element name="LastName" type="xs:string" sql:field="PDNLastName" />
> </xs:sequence>
> <xs:attribute name="id" type="xs:ID"/>
> </xs:complexType>
> </xs:schema>
> I am trying to xpath query the above schema using the following code:
>
> try{
> SqlXmlCommand cmd;
> FileStream f;
> string conString = "Provider=SQLOLEDB;Data
> Source='(local)';database=TestRep; Integrated Security=SSPI";
> cmd = new SqlXmlCommand(conString);
> cmd.Namespaces = "xmlns:x='http://localhost/'";
> cmd.CommandType = SqlXmlCommandType.XPath;
> cmd.CommandText = "x:PatientDetails1";
> cmd.SchemaPath = " F:\\Testing\\XML\\CustomSchema\\CustomSc
hema4.xsd";
> f = new FileStream("F:\\Testing\\XML\\CustomList3.xml", FileMode.Create);
> cmd.ExecuteToStream(f);
> f.Close() ;
> }
> catch(Exception ex)
> {
> string temp = ex.Message;
> MessageBox.Show(temp);
> }
> }
> when I run the above mentioned code it throws the following exception:
> SqlXmlException
> Message="Schema: relationship expected on 'PatientDetails1'."
> "Rainabba" wrote:
>
>
>

Sunday, February 19, 2012

Complete Idiot calling all intelligent lifeforms

Hi all, I run several contact websites. One of them is www.ramc.org.uk - they used to fill in a form and results emailed to me. I then manually copied and pasted into page on server. Very tiresome.

I was hoping with sql express i could create a page where they enter there details into the database after verifying details via a link..... Then as the new details are added they would be displayed on the contacts page in alphabetical order.

Is this really possible or even feasable.

Cheers, your all stars. Mark

Yep, almost all websites where you enter data have the data entered into a database of some sort. The data is usually entered through the webpage.|||

Yes it's possible but it will take some code. My experience is in useing Visual Studio, it can be written in Visual Basic.Net, C# or any other language that will run in Visual Studio. On the web page you would create the form and bind the fields to a SQL database. When the user clicks the submit button on your page the data would be stored in your database. Look for someone with some Visual Studio and SQL experience. It's shouldn't to to hard.

Visual Studio and SQL are all Microsoft stuff. Some people do the same thing using Linux, PHP and MySql.

|||Thanks for your help guys. I need to start looking for a 12 yr old who can do it for me. I'm limited to html. I was hoping i could just link the web page to database then results page display the data. Cheers.|||

Simple usage is not overly complex.

I suggest you visit www.ASP.NET. Under the large GREEN #3 [Learn ASP.NET], there are options for:

ASP.NET Video Tutorials
Starter Kits (Ready Made Sites)