running an .sql script from an asp.net web page

S

Steve Richter

I have the asp.net source of a web application. ( from a great asp.net
book by Wrox )

http://www.amazon.com/exec/obidos/t...002-6140610-0826411?v=glance&s=books&n=507846

The source code includes an sql script that is run to create the
database used by the application.

contains sql stmts like this:
----------------------------------------------
use master
go

IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name =
N'IBuyAdventure')
DROP DATABASE [IBuyAdventure]
GO

CREATE DATABASE IBuyAdventure
GO

exec sp_dboption N'IBuyAdventure', N'autoclose', N'false'
GO
-----------------------------------------------

I used osql to run the script on my PC and everything worked ok.

Now I want to install this web application at my shared hosted web
site. ( as a demo of the great work I can do! )

Is it normal to be able to run "osql" on a shared hosting site like
GoDaddy.com?

If I cant run the script that way, can I run it from .net somehow?

Worst case I would be able to translate the script to a series of
"ExecNonQuery" type method calls, correct? Even the "sp_" stored
procedures can be run that way?

thanks,

-Steve
 
B

Bruce Barker

i doubt if they allow osql, as this would require their sqlsever to open to
the internet. an asp.net page might spawn osql, or you can write your own
sql script page- post a file, and run it . in osql the "go"'s terminate a
batch, so all statments between go's must be sent together

-- bruce (sqlwork.com)
 
S

Steve Richter

Bruce said:
i doubt if they allow osql, as this would require their sqlsever to open to
the internet. an asp.net page might spawn osql,
or you can write your own
sql script page- post a file, and run it .

what do you mean? run the sql script stmts one at a time like so:

SqlConnection conn ;
SqlCommand cmd ;
conn = new SqlConnection( "Server='xxxx';trusted_connection=true;
database='abc'" ) ;
conn.Open( ) ;
cmd = new SqlCommand( "DROP TABLE DemoTable", conn ) ;
cmd.ExecuteNonQuery() ;

thanks,

-Steve

in osql the "go"'s terminate a
batch, so all statments between go's must be sent together

-- bruce (sqlwork.com)



Steve Richter said:
I have the asp.net source of a web application. ( from a great asp.net
book by Wrox )

http://www.amazon.com/exec/obidos/t...002-6140610-0826411?v=glance&s=books&n=507846

The source code includes an sql script that is run to create the
database used by the application.

contains sql stmts like this:
----------------------------------------------
use master
go

IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name =
N'IBuyAdventure')
DROP DATABASE [IBuyAdventure]
GO

CREATE DATABASE IBuyAdventure
GO

exec sp_dboption N'IBuyAdventure', N'autoclose', N'false'
GO
-----------------------------------------------

I used osql to run the script on my PC and everything worked ok.

Now I want to install this web application at my shared hosted web
site. ( as a demo of the great work I can do! )

Is it normal to be able to run "osql" on a shared hosting site like
GoDaddy.com?

If I cant run the script that way, can I run it from .net somehow?

Worst case I would be able to translate the script to a series of
"ExecNonQuery" type method calls, correct? Even the "sp_" stored
procedures can be run that way?

thanks,

-Steve
 
G

Guest

In this case, its better to create a stored procedure with all the script,
and run the stored procedure from the ExecuteNonQuery method.

Steve Richter said:
Bruce said:
i doubt if they allow osql, as this would require their sqlsever to open to
the internet. an asp.net page might spawn osql,
or you can write your own
sql script page- post a file, and run it .

what do you mean? run the sql script stmts one at a time like so:

SqlConnection conn ;
SqlCommand cmd ;
conn = new SqlConnection( "Server='xxxx';trusted_connection=true;
database='abc'" ) ;
conn.Open( ) ;
cmd = new SqlCommand( "DROP TABLE DemoTable", conn ) ;
cmd.ExecuteNonQuery() ;

thanks,

-Steve

in osql the "go"'s terminate a
batch, so all statments between go's must be sent together

-- bruce (sqlwork.com)



Steve Richter said:
I have the asp.net source of a web application. ( from a great asp.net
book by Wrox )

http://www.amazon.com/exec/obidos/t...002-6140610-0826411?v=glance&s=books&n=507846

The source code includes an sql script that is run to create the
database used by the application.

contains sql stmts like this:
----------------------------------------------
use master
go

IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name =
N'IBuyAdventure')
DROP DATABASE [IBuyAdventure]
GO

CREATE DATABASE IBuyAdventure
GO

exec sp_dboption N'IBuyAdventure', N'autoclose', N'false'
GO
-----------------------------------------------

I used osql to run the script on my PC and everything worked ok.

Now I want to install this web application at my shared hosted web
site. ( as a demo of the great work I can do! )

Is it normal to be able to run "osql" on a shared hosting site like
GoDaddy.com?

If I cant run the script that way, can I run it from .net somehow?

Worst case I would be able to translate the script to a series of
"ExecNonQuery" type method calls, correct? Even the "sp_" stored
procedures can be run that way?

thanks,

-Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top