473,666 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What's wrong

I have down load some source codes from the internet and it wasn't worked
right, but I'm really know what's wrong about it. May some expert help me
please...I'm deeply appreciated for your help. Have a nice day...

Kate

the code look like this:
string strPersonSchema = "PersonPet.xsd" ;

XmlDataDocument datadoc = new XmlDataDocument ();
datadoc.Dataset .DataSetName = "PersonPet" ;

// Create tables for people and pets
DataTable people = new DataTable( "Person" );

// Set up the columns in the Tables
DataColumn personname = new DataColumn( "Name", typeof(String) );
DataColumn personAge = new DataColumn( "Age", typeof(Int32) );

// Add columns to person table
DataColumn id = people.Columns. Add( "ID", typeof(Int32) );
id.AutoIncremen t = true;
people.PrimaryK ey = new DataColumn[]{ id };
people.Columns. Add( personname );
people.Columns. Add( personAge );

// Add tables to the DataSet
datadoc.Dataset .Tables.Add( people );

// Create new Row
DataRow mark = people.NewRow() ;
mark[personname] = "Mark";
mark[personAge] = 18;
people.Rows.Add ( mark );

// commit changes
dataset.AcceptC hanges();
try
{
StreamWriter writer = new StreamWriter( strPersonSchema );
datadoc.DataSet .WriteXmlSchema ( writer );
if( writer != null )
writer.Close();
}
catch( Exception Err )
{
MessagBox.Show( Err.Message.ToS tring() );
}

my "PersonPet. xsd" is empty, nothing in it. This might be a problem, hah.


Nov 11 '05 #1
3 1564
Kate Luu wrote:
I have down load some source codes from the internet and it wasn't worked
right, but I'm really know what's wrong about it. May some expert help me
please...I'm deeply appreciated for your help. Have a nice day...
Have you compiled the code? I has some compilation errors, fixing them I got
the schema.
datadoc.Dataset .DataSetName = "PersonPet" ;
datadoc.DataSet .DataSetName = "PersonPet" ;
datadoc.Dataset .Tables.Add( people );
datadoc.DataSet .Tables.Add( people );
dataset.AcceptC hanges();


datadoc.DataSet .AcceptChanges( );

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
Thanks you so much for your help, Oleg, I'm so appreciated.

I don't know why you get it to work. The syntax error just because I typed,
I wasn't copy the code directly from the Visual Studio Environments,
therefore you cannot get it to compile. If you debug line by line, you will
see the execution go to the catch block. One thing I don't understand is the
exception object is "null", which cannot raise the error event, and finally
nothing work. Anyway, Thanks you so much for your help. Have a nice day...

Kate Luu

"Oleg Tkachenko" <oleg@NO_SPAM_P LEASEtkachenko. com> wrote in message
news:eL******** ******@TK2MSFTN GP11.phx.gbl...
Kate Luu wrote:
I have down load some source codes from the internet and it wasn't worked right, but I'm really know what's wrong about it. May some expert help me please...I'm deeply appreciated for your help. Have a nice day...
Have you compiled the code? I has some compilation errors, fixing them I

got the schema.
datadoc.Dataset .DataSetName = "PersonPet" ;


datadoc.DataSet .DataSetName = "PersonPet" ;
datadoc.Dataset .Tables.Add( people );


datadoc.DataSet .Tables.Add( people );
dataset.AcceptC hanges();


datadoc.DataSet .AcceptChanges( );

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3
Kate Luu wrote:
I don't know why you get it to work. The syntax error just because I typed,
I wasn't copy the code directly from the Visual Studio Environments,
therefore you cannot get it to compile. If you debug line by line, you will
see the execution go to the catch block.


Nope, it works like a charm to me. Just tried it again, now in VS.NET
2003. It runs ok and doesn't go to the catch block. Resulting schema is:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="PersonPet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="PersonPet " msdata:IsDataSe t="true"
msdata:Locale=" ru-RU" msdata:EnforceC onstraints="Fal se">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Person">
<xs:complexType >
<xs:sequence>
<xs:element name="ID" msdata:AutoIncr ement="true"
type="xs:int" />
<xs:element name="Name" type="xs:string " minOccurs="0" />
<xs:element name="Age" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constrain t1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//Person" />
<xs:field xpath="ID" />
</xs:unique>
</xs:element>
</xs:schema>
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #4

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

Similar topics

72
5835
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for example, between a C/C++ programmers with a few weeks of experience and a C/C++ programmer with years of experience. You don't really need to understand the subtle details or use the obscure features of either language
121
10029
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
28
3263
by: Madhur | last post by:
Hello what about this nice way to open a file in single line rather than using if and else. #include<stdio.h> void main() { FILE *nd; clrscr(); fopen("c:\\autoexec.bat","r")&&printf("success") || printf("error opeing
65
625
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for example, between a C/C++ programmers with a few weeks of experience and a C/C++ programmer with years of experience. You don't really need to understand the subtle details or use the obscure features of either language
13
5035
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
0
8454
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
8362
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8785
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...
1
8560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8644
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
7389
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...
1
6200
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5671
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
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.