Connecting Tech Pros Worldwide Forums | Help | Site Map

running sql script from ASPx page

LIN
Guest
 
Posts: n/a
#1: Nov 18 '05
Is it possible to run a big .sql file - SQL script to create a database from
a ASPx page? If yes, please advice how can I achieve this?

Thanks!

LIN



James Hokes
Guest
 
Posts: n/a
#2: Nov 18 '05

re: running sql script from ASPx page


LIN,

0.) Write your SQL Script, and save to disk.
1.) Create the aspx page.
2.) Create an ADO connection in the aspx page.
3.) Open the ADO connection.
4.) Load the SQL Script from disk using FSO & TextStream.
5.) Run the script using the ADO connection's Execute method.
6.) Close connection
7.) End Script
8.) Lather, rinse, repeat

James Hokes

"LIN" <junkvaluesnotallowed@football.com> wrote in message
news:uIh1Z%23A1DHA.2184@TK2MSFTNGP12.phx.gbl...[color=blue]
> Is it possible to run a big .sql file - SQL script to create a database[/color]
from[color=blue]
> a ASPx page? If yes, please advice how can I achieve this?
>
> Thanks!
>
> LIN
>
>[/color]


LIN
Guest
 
Posts: n/a
#3: Nov 18 '05

re: running sql script from ASPx page


great. good idea. But how do I exactly use the textstream object to read
line by line and execute.
Do I need to put a for loop or something? Please advice.

Thanks a ton for the help. Its much appreciated.

LIN

"James Hokes" <noemail@noway.com> wrote in message
news:uJg40FB1DHA.3468@TK2MSFTNGP11.phx.gbl...[color=blue]
> LIN,
>
> 0.) Write your SQL Script, and save to disk.
> 1.) Create the aspx page.
> 2.) Create an ADO connection in the aspx page.
> 3.) Open the ADO connection.
> 4.) Load the SQL Script from disk using FSO & TextStream.
> 5.) Run the script using the ADO connection's Execute method.
> 6.) Close connection
> 7.) End Script
> 8.) Lather, rinse, repeat
>
> James Hokes
>
> "LIN" <junkvaluesnotallowed@football.com> wrote in message
> news:uIh1Z%23A1DHA.2184@TK2MSFTNGP12.phx.gbl...[color=green]
> > Is it possible to run a big .sql file - SQL script to create a database[/color]
> from[color=green]
> > a ASPx page? If yes, please advice how can I achieve this?
> >
> > Thanks!
> >
> > LIN
> >
> >[/color]
>
>[/color]


LIN
Guest
 
Posts: n/a
#4: Nov 18 '05

re: running sql script from ASPx page


I figured how to read all the lines but not sure how to execute it.. i
stored it in a variable called STR and passed it to execute statement.

Please advice.

Thanks
LIN


"LIN" <junkvaluesnotallowed@football.com> wrote in message
news:#oO$FpE1DHA.2456@TK2MSFTNGP12.phx.gbl...[color=blue]
> great. good idea. But how do I exactly use the textstream object to read
> line by line and execute.
> Do I need to put a for loop or something? Please advice.
>
> Thanks a ton for the help. Its much appreciated.
>
> LIN
>
> "James Hokes" <noemail@noway.com> wrote in message
> news:uJg40FB1DHA.3468@TK2MSFTNGP11.phx.gbl...[color=green]
> > LIN,
> >
> > 0.) Write your SQL Script, and save to disk.
> > 1.) Create the aspx page.
> > 2.) Create an ADO connection in the aspx page.
> > 3.) Open the ADO connection.
> > 4.) Load the SQL Script from disk using FSO & TextStream.
> > 5.) Run the script using the ADO connection's Execute method.
> > 6.) Close connection
> > 7.) End Script
> > 8.) Lather, rinse, repeat
> >
> > James Hokes
> >
> > "LIN" <junkvaluesnotallowed@football.com> wrote in message
> > news:uIh1Z%23A1DHA.2184@TK2MSFTNGP12.phx.gbl...[color=darkred]
> > > Is it possible to run a big .sql file - SQL script to create a[/color][/color][/color]
database[color=blue][color=green]
> > from[color=darkred]
> > > a ASPx page? If yes, please advice how can I achieve this?
> > >
> > > Thanks!
> > >
> > > LIN
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Dan Boylett
Guest
 
Posts: n/a
#5: Nov 18 '05

re: running sql script from ASPx page



"LIN" <junkvaluesnotallowed@football.com> wrote in message
news:%23QXZ79E1DHA.2480@TK2MSFTNGP10.phx.gbl...[color=blue]
> I figured how to read all the lines but not sure how to execute it.. i
> stored it in a variable called STR and passed it to execute statement.
>
> Please advice.
>[/color]

Create a command object, set it's commandtext to be your variable, Execute
it.

MSDN has lots (and lots and lots) of examples of ADO.NET commands, datasets
and connections.





LIN
Guest
 
Posts: n/a
#6: Nov 18 '05

re: running sql script from ASPx page


yes I am using CommandText only .. the problem is I am reading from a .SQL
file and hence I need to execute multiple lines. Using FSO i am storing the
string in a variable - however the string concatinates the whole SQL script
and code doesn't seem to work.

What am I doing wrong?

LIN





"Dan Boylett" <parc_erom@crossdata.co.uk> wrote in message
news:uzjgMEF1DHA.2888@tk2msftngp13.phx.gbl...[color=blue]
>
> "LIN" <junkvaluesnotallowed@football.com> wrote in message
> news:%23QXZ79E1DHA.2480@TK2MSFTNGP10.phx.gbl...[color=green]
> > I figured how to read all the lines but not sure how to execute it.. i
> > stored it in a variable called STR and passed it to execute statement.
> >
> > Please advice.
> >[/color]
>
> Create a command object, set it's commandtext to be your variable, Execute
> it.
>
> MSDN has lots (and lots and lots) of examples of ADO.NET commands,[/color]
datasets[color=blue]
> and connections.
>
>
>
>
>[/color]


Dan Boylett
Guest
 
Posts: n/a
#7: Nov 18 '05

re: running sql script from ASPx page



"LIN" <junkvaluesnotallowed@football.com> wrote in message
news:ex12bVF1DHA.2160@TK2MSFTNGP12.phx.gbl...[color=blue]
> yes I am using CommandText only .. the problem is I am reading from a .SQL
> file and hence I need to execute multiple lines. Using FSO i am storing[/color]
the[color=blue]
> string in a variable - however the string concatinates the whole SQL[/color]
script[color=blue]
> and code doesn't seem to work.
>
> What am I doing wrong?
>
> LIN[/color]

Have you tried debugging what you're pulling in from the file, before you
execute it?

Also, are you reading the file one line at a time, or the whole lot? If it's
one line at a time, you will need to add in spaces after each line,
otherwise you'll get syntax problems.


Closed Thread