Monday, March 19, 2012

Creating SQL Schema using objects not script?

Hey new in the .NET SQLDMO thing...

Can you in C# programtically create a SQL DB and then create tables, references etc...programmatically without having to use Sql scripting?

What is the root namespace for this anyone?

Thanks ideas on examples much appreciated!No. SQL is a bridge between programming language and Database, so far.|||Does not matter...

I used a combination of XSD and DataSets to come up with a decent enough solution.

Eric|||Yes, you could use XML/XSL to access SQL Server with appropriate setup of SQL Server, but it seems you still need to use a combined SQL script.

Anyway, do you mind to share your sample with us?|||Yep...or use SQLXML3.0 ...

I think you can do that with and OleDb connection objects..create Schema structures in SQL.

I have it working with and AccessDB right now...using T-SQL script source dynamically.

Thanks,

Eric|||I knew and used SQLXML 3.0 and even previous version well in VS 6.0 age, but now it seems the trick has been replaced by Web Service in most scenarios. I am curious of your using XSD associated with DataSet. If with several line code you could demo the sample, would you please show me the code? Otherwise, never mind.|||yeah it is quite large...really...

I only had to do it because the XSD.exe tool barfed on my XSD it was simply too large...So had to do it manually.

But its' simply creating a defintion file for the data structure in an xsd...define tables, rows, columns, types ect...the use the XSD.exe tool and it will generate a strongly typed dataset deriving from your data structure xsd template.

now you can use that strongly typed class as destination source....iterate over your xsd find what you need to define xsd:complexTypes and xsd:elements etc...then use the strongly typed collection ..

myClassTable.Add("xsdElementToBeNamedATable") etc..for type defs column defs etc...

Then you have a complete composite structure of your db in a DataSet....you can create what ever you want from this...out put the xsd again..if you want etc...

Now you can iterate over the DataSet Tables and create your T-SQL script on that structure. Alternatively you can use a straight XmlSchema iteration over the XSD document and then inline your T-SQL script code during the looping over the various types...xsd:attributes, xsd:sequences, xsd:elements etc...

It's kinda hairy at first.

LOL|||It's kinda hairy at first.

Yes, you are right. I believe so. But, what is your reason to do so? Do you try to reach the database through HTTP protocol?|||Customer provided me a schema and nothing else...

Build me a DB...

No ERD nothing just this monster of an XSD. to the tune of like 30 imports and a file size of like 500k...humongous...

Every tool on the market barfed when trying to parse the XSD.

I have 2 Gig on my machine and serious hardware...the problem is that XMLSpyEnterprise is the only tool that I have seen any bright spots with. I wish you could modify the amount of ram that the tool uses...like the java engines allow you to do...it just runs out of memory...the program stack is simply too small.

Eric|||OK, understandable.

Although the XML stuff (including XSD) seems a new and advanced technology, it has never been a normal release as a tool for Microsoft products until the .NET age when the XML technology is still not explicitly used but with the form of Web Service. In fact, Web Service is called XML Web Service, it could let you use XML/SOAP protocol wihtout expert knowledge on it, actually without XML/SOAP knowledge on it.

In your case, you somehow has a legacy product from your customer with it quite troublesome. If this is a small piece or you have no way to control it, you might just keep it and use it. Otherwise, you'd better to upgrade it to Web Service to enjoy the advantage of .NET.

This thread,248757, might help you, too.|||Actually,

They want a DB for all kinds of reasons...I am under NDA so I can't say too much other than it involves InfoPath, Office2003, SharePont Server V2.0, SQLServer and a host of XML technologies...very cool stuff..

LOL|||Web services are fairly trivial...I mean I like then and use them for my own corporate stuff. It's a fantastic technology combine it with the WSDL.exe can you got some seriously cool prodcutvitiy tools for creating strongly typed web serviced classes.

This is different...how is using a web service going to solve my DB problem?

Just curious...

Eric|||You didn't state your DB or other problems clearly, how can I know the way to solve them. I even don't know your structure of the problem, and don't know if your problem need to use either XML or Web Service. Basically, the XML/SOAP technology is used for interplatform/interlanguage communications through HTTP protocol. A lot of people use them just in a not necesary scenatio. But, this might not be your case. You think your job is fantastic, that is fantastic.

No comments:

Post a Comment