473,944 Members | 19,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Server DB to XSD - can it be done thru code

Hi

In C# ide if you have a SqlServer attached and Create a New XSD Item in a
solution you can then drag a db from the SQLServer and ti creates a XSD
modelled after the db. Can this be done thru code???

If I have a EXE that is passed a db can I generate a XSD on the fly???

Thanks
Jul 9 '08 #1
3 2062
sippyucon,

You ^might^ be able to get it through a call to GetSchema on a
SqlConnection. This will return a DataTable, which you might be able to use
to create the XSD schema for the table in question.

My guess, though, is that this won't give you what you want, and that
the functionality you are seeing is IDE-specific, and not accessible through
the framework (which means you will have to do this on your own).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"sippyuconn " <si********@new sgroup.nospamwr ote in message
news:36******** *************** ***********@mic rosoft.com...
Hi

In C# ide if you have a SqlServer attached and Create a New XSD Item in a
solution you can then drag a db from the SQLServer and ti creates a XSD
modelled after the db. Can this be done thru code???

If I have a EXE that is passed a db can I generate a XSD on the fly???

Thanks

Jul 9 '08 #2
You can generate a schema from a DataSet, so either construct one in code or
Fill one with a DataAdapter and call the GetXmlSchema function which returns
it as a string.

e.g:

DataSet ds = new DataSet();

ds.Tables.Add(" table 1");
ds.Tables[0].Columns.Add("c ol1", typeof(int));
ds.Tables[0].Columns.Add("c ol2", typeof(DateTime ));
ds.Tables[0].Columns.Add("c ol3", typeof(string)) ;
ds.Tables[0].Columns.Add("c ol4", typeof(Guid));

File.WriteAllTe xt("C:\\sch.xsd ",ds.GetXmlSche ma());

this makes:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="NewDataSet " xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSe t" msdata:IsDataSe t="true"
msdata:UseCurre ntLocale="true" >
<xs:complexType >
<xs:choice minOccurs="0" maxOccurs="unbo unded">
<xs:element name="table_x00 20_1">
<xs:complexType >
<xs:sequence>
<xs:element name="col1" type="xs:int" minOccurs="0" />
<xs:element name="col2" type="xs:dateTi me" minOccurs="0" />
<xs:element name="col3" type="xs:string " minOccurs="0" />
<xs:element name="col4" msdata:DataType ="System.Gui d,
mscorlib, Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
type="xs:string " minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"sippyuconn " wrote:
Hi

In C# ide if you have a SqlServer attached and Create a New XSD Item in a
solution you can then drag a db from the SQLServer and ti creates a XSD
modelled after the db. Can this be done thru code???

If I have a EXE that is passed a db can I generate a XSD on the fly???

Thanks
Jul 10 '08 #3
that creates a xml including the schema:

SELECT * from [tablename] FOR XML AUTO, XMLSCHEMA, ELEMENTS, ROOT
('tablename')
"sippyuconn " wrote:
Hi

In C# ide if you have a SqlServer attached and Create a New XSD Item in a
solution you can then drag a db from the SQLServer and ti creates a XSD
modelled after the db. Can this be done thru code???

If I have a EXE that is passed a db can I generate a XSD on the fly???

Thanks
Jul 25 '08 #4

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

Similar topics

1
1653
by: Miguel Guerreiro | last post by:
Hello good folks! I need your advice on a project that i am working on. I am integrating a signature pad, a client-side web browser, and my extranet to make a system. In this system, a user can punch in numbers in the signature pad, which are then sent (thru some sort of VB component) to the current page opened by the user's web browser. After that the user presses a SUBMIT button and the numbers are sent to my web-server so I can...
9
1305
by: Tony Epton | last post by:
I have done a partial conversion of a large MS Access batch processing program to use a SQL server 2000 back end. All I have done is move all the access tables in to SQL server and give them primary keys so that tje Access front end can attach to them as updateable tables. No pass thru queries or anything that will take advantage of the SQL facilities. In my development environment I am running Access 97 on Windows 98. The client is...
7
7250
by: astro | last post by:
Anyone have suggestions on where to troubleshoot this error? Background: -Access 2k v. 9.0.6926 sp3 - front and backend on production server (wiindows 2k) -accessed via Citrix -front-end is mde, backend is mdb -only occurs on the production server -only occurs with mde verson - i've tested the problem with the mdb version of the front-end and it loads/generates the document fine on the production
8
3133
by: Brendan Reynolds | last post by:
I'm trying to integrate SQL Server Reporting Services reports into an ASP.NET app (SRS 2000, ASP.NET 1.1). I know how to do this using direct URL addressing, but this exposes in the query string parameters that should not be exposed. Each user is associated with a school, and should see only that school's data. When the user logs in, I retrieve the SchoolID associated with that user, and that SchoolID is used as a parameter in all stored...
3
7779
by: Wild Wind | last post by:
Hello all, I apologise in advance for the long windedness of this post, but I feel that if I am going to get any solution to this problem, it is important that I present as much information that will be useful in diagnosing the problem. I have an application which calls a method of a web service that we host remotely. I have deployed the application to a
3
2844
by: Robert W. | last post by:
I have a SQL Server table called "ClosedMonths" that contains two pertinent fields: Yearx Monthx 2000 1 2000 2 2000 3 I want to simply query this table and populate a WebControls listbox with
2
2279
by: nitin | last post by:
HI all Gurus i am struck up in sql 2005.I am new to sql 2005.I have my server installed on one machine.Now what do i download so that i am able to register it. Now i want to connect to that machine thru enterprise manager or client like we do in sql server 2000 thru query analyzer.. Will sql 2005 express help.? Please help Regards
1
1636
by: sahoong | last post by:
WEB DATABASE DEVELOPMENT I have a basic knowledge of HTML, PHP and MySQL. I needed to build a web page through which visitors to the page can fill form and upload the cv into the database. Also, I need other users like prospective employers to be able to search though the database for registered users. I have done similar exercise b4 but it was done in my university where i login in to the unix thru telnet to use sql to build the...
1
2333
BeemerBiker
by: BeemerBiker | last post by:
I am using CancelAsyncPostback in an attempt to stop a page from loading. It actually works (the page wont get a postback) but the server keeps running, processing data I dont want processed until it gets done with a task I really didnt want done because I didnt realize how long it took I tried adding a button to do a server transfer to "./Default.aspx" but it only transfered AFTER the processing was complete. what I tried that didnt work...
0
10145
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
11134
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
11307
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
9868
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
8236
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
7397
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
6090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4920
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4516
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.