|
-
Mar 16th, 2002, 01:40 PM
#1
Thread Starter
Lively Member
Problems
Why can't I use server in a VBScript function like this:
<script language="VBScript">
sub Inlogg()
alias=trim(formen.alias.value)
losen=trim(formen.losen.value)
self.status=alias & "..." & losen
set ConMitt = Server.CreateObject("ADODB.Connection")
ConMitt.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("/ps014/Community2/") & "\medlemmar.mdb"
Set RsMitt = Server.CreateObject("ADODB.Recordset")
SQLstr = "SELECT * FROM gaster ORDER BY Tid ASC"
rsMitt.Open SQLstr, ConMitt
Do Until RsMitt.EOF
a1=RsMitt("Alias")
a2=RsMitt("Losen")
rsMitt.MoveNext
Loop
RsMitt.close
Set RsMitt= Nothing
ConMitt.close
Set ConMitt = Nothing
self.status=a1 & "..." & a2
end sub
</script>
I can use in regular HTML-code if I use <% %>.
How do I solve this problem ??
Thanks,
Abel
-
Mar 18th, 2002, 04:05 AM
#2
Hyperactive Member
Try taking off the Server option in from these lines
set ConMitt = Server.CreateObject("ADODB.Connection") And
Set RsMitt = Server.CreateObject("ADODB.Recordset")
When usinb VB script like this, you don't use 'Server'
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Mar 18th, 2002, 10:27 AM
#3
Frenzied Member
You are trying to do server side work in client side script.
Keep your recordsets on the server side.
You also can't use server.createobject in client side code. If you did execute this code without the server. object identifyer, the user would get an error if they didn't have ADO installed.
If you are creating objects, keep them server side and always use Server.CreateObject
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|