Hi,

I need to create an application that would connect to an SQL Server and
create a database with all tables and relations needed.

I have never done something like this before, I know that an easy way to do
the same is to create a text file with all "CREATE" statements and run it on
the server. However, I have to do it programatically from a VB.net
application.

I need some help on that. Is this a good way to do it? How to do it? etc

Any help will be appreciated
Dino

--


-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com

Re: Creating a database by William

William
Thu Jan 22 12:39:00 CST 2004

Dino:

Provided you have the permissions to create a db and the respective
objects..you can just set your commandtext to the DDL statements "CREATE
TABLE someTable".... and then use ExecuteNonQuery to create it. So as far
as a text file goes, you could do both or leave it out---but you could read
in the text into a string, set your command's commantext to it and execute
the statement.

HTH,

Bill
"Dino M. Buljubasic" <dino.buljubasic([no spam])@rivusglobal.com> wrote in
message news:wSSPb.40868$Eq.2917@clgrps12...
> Hi,
>
> I need to create an application that would connect to an SQL Server and
> create a database with all tables and relations needed.
>
> I have never done something like this before, I know that an easy way to
do
> the same is to create a text file with all "CREATE" statements and run it
on
> the server. However, I have to do it programatically from a VB.net
> application.
>
> I need some help on that. Is this a good way to do it? How to do it?
etc
>
> Any help will be appreciated
> Dino
>
> --
>
>
> -------------------------------------------------------------------------
> FIGHT BACK AGAINST SPAM!
> Download Spam Inspector, the Award Winning Anti-Spam Filter
> http://mail.giantcompany.com
>
>
>



Re: Creating a database by Dino

Dino
Thu Jan 22 12:43:54 CST 2004

Hi William,

could you tell me little bit more about "creating a text file, copying it to
a string variable, and passing that variable to command's command text
property". I think that would be a good way to go for since I could start
doing this task by creating a text file and testing it thoroughly at the
server by copying it to Query Analizer. Then once everythng works
perfectly, I could just copy that text file context into string variable.

I am wondering though if my string variable is going to be able to hold so
meny characters. I need to create about 10 tables plus all the
relationships among them.

What do you think? Would this be a good way to do it?

Regards, Dino

--


-------------------------------------------------------------------------
FIGHT BACK AGAINST SPAM!
Download Spam Inspector, the Award Winning Anti-Spam Filter
http://mail.giantcompany.com


"William Ryan" <dotnetguru@comcast.nospam.net> wrote in message
news:uh2m$ZR4DHA.2384@TK2MSFTNGP10.phx.gbl...
> Dino:
>
> Provided you have the permissions to create a db and the respective
> objects..you can just set your commandtext to the DDL statements "CREATE
> TABLE someTable".... and then use ExecuteNonQuery to create it. So as far
> as a text file goes, you could do both or leave it out---but you could
read
> in the text into a string, set your command's commantext to it and execute
> the statement.
>
> HTH,
>
> Bill
> "Dino M. Buljubasic" <dino.buljubasic([no spam])@rivusglobal.com> wrote in
> message news:wSSPb.40868$Eq.2917@clgrps12...
> > Hi,
> >
> > I need to create an application that would connect to an SQL Server and
> > create a database with all tables and relations needed.
> >
> > I have never done something like this before, I know that an easy way to
> do
> > the same is to create a text file with all "CREATE" statements and run
it
> on
> > the server. However, I have to do it programatically from a VB.net
> > application.
> >
> > I need some help on that. Is this a good way to do it? How to do it?
> etc
> >
> > Any help will be appreciated
> > Dino
> >
> > --
> >
> >
>
> -------------------------------------------------------------------------
> > FIGHT BACK AGAINST SPAM!
> > Download Spam Inspector, the Award Winning Anti-Spam Filter
> > http://mail.giantcompany.com
> >
> >
> >
>
>



Re: Creating a database by anonymous

anonymous
Thu Jan 22 20:31:05 CST 2004

Here's a quick way to get the commands in a text file if you have SQL Server's Enterprise manager. First create the table in SQL Server. Then, select the table, right click and select "All Tasks" and then select "Generate SQL Script". You'll get a dialog box that lets you identify the specifics of the table's definition that you want scripted. What you'll end up with is a .sql file (open it with NotePad or even Visual Studio). Then, you can dissect the script into the various CREATE and ALTER TABLE statements and run these statements from within the commandtext of a SQL command

Michael