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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server is need ...

Status
Not open for further replies.

daniloa

Programmer
Nov 23, 2001
27
BR

Hi friends how are you?

I'm a begginer with ASP and HTML programs.
So bellow is my test code, where I put a button and a little vbscript for him.

The page load ok, but when I click on the button called "cmdpesquisa" I get a script error message like:

object need: Server

What is going on???

I'm using Win2K pro with IIS (native), and DreamWherer Ultradev.

Very Thanks.

<input type=&quot;button&quot; name=&quot;cmdpesquisa&quot; value=&quot;Pesquisa&quot; onclick=&quot;P&quot;>

<script language=&quot;VbScript&quot;>
Sub P()
Dim vCod
Dim Cn
Dim Rs

Set Cn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set Rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;)

Cn.ConnectionString = &quot;Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Danilo;Data Source=DEMO01&quot;
Cn.ConnectionTimeOut = 50

vCod = Request.frmDados(&quot;txtcodigo&quot;)
Rs.Open &quot;Select Nome From Teste Where Codigo = &quot; & vCod & &quot;&quot;

If Not Rs.EOF() Then
frmDados.txtnome.value = Rs(&quot;Nome&quot;)
Else
Msgbox &quot;Nenhum Registro Encontrado !!!&quot;
End If

Rs.Close
Cn.Close

Set Cn = Nothing
Set Rs = Nothing

End Sub
</script>
 
You are using client side code to perform your database connection. Remove the Server form Server.Createobject.

Server.createobject is used for server side vbscript.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top