Urgent Please help..

S

Saps

Hi all. Can anyone help me here. I have loads of .sql files and i need
a way to call these from my asp page so the user can run them from the
browser. Meaning i have a page with a list of all scripts. each when
clicked i am able to run the script. so HOW and what do i do to call
and run the .sql
Thanks
 
E

Evertjan.

Saps wrote on 04 jul 2006 in microsoft.public.inetserver.asp.general:
Hi all. Can anyone help me here. I have loads of .sql files and i need
a way to call these from my asp page so the user can run them from the
browser. Meaning i have a page with a list of all scripts. each when
clicked i am able to run the script. so HOW and what do i do to call
and run the .sql

"Urgent" only pisses off the helpful people in this NG.

What is an .sql file?
It seems not part of classic ASP, the NG's subject.
 
S

Saps

Why does urgent have to piss someone cuz im really in need of help
here. anyways a .sql file is a sql script file which needs to be run
from a classic ASP page.
 
A

Anthony Jones

Saps said:
Hi all. Can anyone help me here. I have loads of .sql files and i need
a way to call these from my asp page so the user can run them from the
browser. Meaning i have a page with a list of all scripts. each when
clicked i am able to run the script. so HOW and what do i do to call
and run the .sql
Thanks

What do the SQL files contain? SQL Server T-SQL?
Do they contain multiple batches? (I.e. do they use the GO key word)
Are you familiar with ADO?
 
E

Evertjan.

Saps wrote on 04 jul 2006 in microsoft.public.inetserver.asp.general:
[please do not toppost on usenet, the same pisses off applies]
Why does urgent have to piss someone

It does not have to, off.
It is just the way it is.
People will answer in their own good time.
cuz im really in need of help here.

Evenso. This applies to most OQ's here.
A meaningful subjectfield text would help more. [field changed]
anyways a .sql file is a sql script file which needs to be run
from a classic ASP page.

Whose "need"?

It seems native classic ASP does not support it, based on the minute
info you give about the content of such files.

So another executing engine needs to be introduced,
and perhaps the type of database it is intended to run on.

Can you give info about that, Saps?
What DB and what DB-engine are you running?
 
E

Evertjan.

Anthony Jones wrote on 04 jul 2006 in
microsoft.public.inetserver.asp.general:
Are you familiar with ADO?

I met him in the theatre the other day.

Much ADO about nothing, he said.

It was like Jmail talking about the do's and don'ts of CDO and CDONT.

;-)
 
S

Saps

The SQL file contains multiple select statements created using notepad,
that would obviously return some information. Yes I am familiar with
ADO. Currently if there are 3 sets of SQL statements, they are nt
separated by any GO. Altho i can impose them a format if required to
run from ASP.
Where i work, we have a set of users who develop these clean up
scripts(sql select statements) and upload them in a particular folder.
The target users who access this site are meant to execute these SQL
statements so they get the rows of data that the script returns. I know
its much simpler if the creators just give me the statements and i use
them ASP but its a matter of making it dynamic, they create and upload,
the users sees it and runs it.
thx for bearing with me and help will greatly b appreciated.
 
C

CJM

Saps said:
Hi all. Can anyone help me here. I have loads of .sql files and i need
a way to call these from my asp page so the user can run them from the
browser. Meaning i have a page with a list of all scripts. each when
clicked i am able to run the script. so HOW and what do i do to call
and run the .sql
Thanks

There is no native way that I know of, but I don't see why you can't just
read the T-SQL from the files and execute it via ADO.

It sounds a bit messy to me though, and we have no context in which to
answer. What do the scripts do? Who creates them? Who uses the application
(security may be an issue). What kind of SQL is being used?

More importantly, what are you trying to achieve? Why do you want users to
be about to run SQL scripts from ASP?

CJM
 
M

MFedatto

Saps said:
Hi all. Can anyone help me here. I have loads of .sql files and i need
a way to call these from my asp page so the user can run them from the
browser. Meaning i have a page with a list of all scripts. each when
clicked i am able to run the script. so HOW and what do i do to call
and run the .sql
Thanks

Sapa,

I've never used something like that, but considering that the sql
command in ASP is an ordinary string, I believe taht you may do what
you wnat by FSO.
Try to read the sql file and put its contents on a string and them
execute the command object.
 
R

Rob Meade

...
I met him in the theatre the other day.

Much ADO about nothing, he said.

It was like Jmail talking about the do's and don'ts of CDO and CDONT.

;-)

For one so keen on the "rules" your post was kind OT wasn't it ;o)

And yes, I do appreciate the irony of my reply, and most likely
yours.....here we go! :eek:)

Regards

Rob
 
B

Bob Barrows [MVP]

Saps said:
Hi all. Can anyone help me here. I have loads of .sql files and i need
a way to call these from my asp page so the user can run them from the
browser. Meaning i have a page with a list of all scripts. each when
clicked i am able to run the script. so HOW and what do i do to call
and run the .sql
Thanks
You would probably be better off if you encapsulated the T-SQL in those
script files into stored procedures which can easily be executed from an ASP
file via ADO.

CREATE PROCEDURE RunMySQL1 AS
<copy and paste your sql script file contents here>

Run the above script on your server, grant the appropriate permissions to
the users that need to run it, and, in your ASP page:

dim cn, proc
proc = request.form("selectedscript")
set cn=createobject("adodb.connection")
cn.open <your connection string>
'http://www.aspfaq.com/show.asp?id=2126
select case proc
case "1": cn.RunMySQL1
...
case else:
end select
cn.close: set cn=nothing

What is your perceived advantage in using script files instead of stored
procedures?

If you are stuck with script files, you have several options:
1. As stated by MFedatto, you can use FSO to read the sql from the file
(http://www.aspfaq.com/show.asp?id=2039) and execute it using an ADO
connection object. With this approach, you need to take care to strip out
non-T-SQL words like "GO"

2. Depending on your version of SQL Server, you can install either isql or
osql (look them up in SQL Books Online ... BOL) on your web server and use
wscript.shell to run the script files using the appropriate tool for your
sql server.

3. Again, depending on your version of SQL Server, install either SQL-DMO or
SMO (if using SQL 2005) and use them to run your script files (look them up
in BOL)
 
A

Anthony Jones

Saps said:
The SQL file contains multiple select statements created using notepad,
that would obviously return some information. Yes I am familiar with
ADO. Currently if there are 3 sets of SQL statements, they are nt
separated by any GO. Altho i can impose them a format if required to
run from ASP.

Not having GO is a good thing.

As others have pointed out you could simply load the text of the file via
Scripting.FileSystemObject and execute the script via ADO.

You would have to impose that GO is not used since it's used to delimit
batches to be executed which is a facility not offered by ADO.
 
K

Kyle Peterson

I think the more relevent issue is that your Subject should mention
something about the question your asking.
This helps keep the newgroup posts clean and easier to look through.

"Urgent Please help.."

Is an annoying and useless Subject title. At least to me it is.

Your also going to get a lot less people reading a post with a subject like
that.





Saps said:
Why does urgent have to piss someone cuz im really in need of help
here. anyways a .sql file is a sql script file which needs to be run
from a classic ASP page.
 
B

Bob Barrows [MVP]

Kyle said:
I think the more relevent issue is that your Subject should mention
something about the question your asking.
This helps keep the newgroup posts clean and easier to look through.

"Urgent Please help.."

Is an annoying and useless Subject title. At least to me it is.

Your also going to get a lot less people reading a post with a
subject like that.


You know, I would typically agree with that statement, but ...
compare the number of responses in this thread to the number of responses
the original thread (subject: "Execute .sql scripts from ASP") received ...
;-)
 
K

Kyle Peterson

I never saw that anywhere.


original thread (subject: "Execute .sql scripts from ASP")
 
S

Saps

Yes Bob. i had posted this question when i was in most need of help.
and when i open to chk if anyone replied..NOONE did. i had to put it
this way for people to atleast open it and chk if they can help. but
anyways i have really appreciated the help i gt. yes like u guys
mentioned, i can read each line of the script store it in a string and
execute it. im going to have to try doing that. Can i get a sample code
of how to do that tho. Please.
And hey guys sorry for all the botherations u'll had answering this
thread but it has helped me ALOT. thx.
 
B

Bob Barrows [MVP]

Saps said:
Yes Bob. i had posted this question when i was in most need of help.
and when i open to chk if anyone replied..NOONE did. i had to put it
this way

No, you didn't. You could (should) have replied to the original post.
for people to atleast open it and chk if they can help.
but
anyways i have really appreciated the help i gt. yes like u guys
mentioned, i can read each line of the script store it in a string and
execute it. im going to have to try doing that.

Why do you have to use .sql files? You have yet to answer this question.
SQL files are not really a good mechanism for implementing application
logic. They are really meant for maintenance tasks that are infrequently
performed.
Can i get a sample
code of how to do that tho. Please.

Unless someone has a lot of time on his hands (or is intrigued by the
problem), nobody is going to write it for you. Look at the link I
provided (http://www.aspfaq.com/show.asp?id=2039), do some reading in
the other articles on that site, and try doing it yourself. If you get
stuck, come back and show us where you are stuck.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top