Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help getting dsn-less connection to sql server

Status
Not open for further replies.

jpicks

MIS
Oct 11, 2002
158
US
I am having trouble getting a dsn-less connection to a sql 2000 server using vbscript in a asp page.

I am trying to make the connection in a vbscript function and then call the function from an onClick button event.

I tested the connection code in a seperate blank asp page without putting it in a function and it worked fine. As soon as I include it in a function I am recieving the following error:

Error: Object required: 'Server'

Here is the function that I am using:
Code:
<script language = vbscript>
function test() 
    Dim strConn, objConn 
    strConn = &quot;Provider=SQLOLEDB.1;SERVER=ip address;DATABASE=MASTER;UID=SA;PWD=password&quot;
    Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
    objConn.Open(strConn)
    objconn.Execute(&quot;sp_dtsPackage&quot;)   
    objConn.close
    Set objConn = Nothing 
end function
</script>

Here is my function call:
Code:
<BUTTON TYPE=BUTTON onClick=test()><p>Update Accounts</BUTTON>
[code]

I am new to asp and vbscript and would appreciate any help you can give.

Thanks in advance.

-Jim
 
A button is clicked by the user that is looking at the page in a web browser. You are not connected to the web server. HTTP is a stateless environment. You are getting confused what code can be run where. You would need your button click to submit to an asp page to do the work.

If you view the source of your web page you will notice everyone can see your database user id and password. I don't think that is what you intend.

Thanks,

Gabe
 
I think if you are going to be DSNless, you still have to Server.MapPath (&quot;db object&quot;), don't you?
 
ITintern,
You've confused between client-side code and server-side code ... your onClick event is a client side code (executed on the client), while the Server.CreateObject is, well, a server-side code. You cannot create a connection this way to the server. The code needs to be executed on the server-side.

regards,
- Joseph ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Visit --> for (Replica) Watches, Pen, Handbags, Hats, Jerseys and more ... at prices that makes your code spin ...
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
 
I see what you mean. I want everything to run server side.

Thanks to all for your replies!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top