Luke
Luke

Reputation: 527

ASP Object required: 'Server

i try to handle an http get and insert the get data in my oledb database using an asp web application on visual studio 2012. I create an html item and i change the extention from html to asp.

this is my code:

<%

    'declare the variables 
    Dim Connection
    Dim Recordset
    Dim SQL
    Dim objRS
    Dim objConn


    Dim  strConnect



    'Option Explicit

    Dim nome, ID

    nome = Request.Querystring("Name")
    ID = Request.Querystring("Id")

    'declare the SQL statemant that will query the db
    SQL = "INSERT INTO tablename (NomeFileNotifica, IDErrore, ISNew) VALUES ('"+nome+"', "+ ID +", 1)"


    StrConnect = "PROVIDER=MICROSOFT.JET.OLEDB.4.0; Data Source = ***; Database = dbname; User ID = username; Password=password;"

    Set objConn = Server.CreateObject(ADODB.Connection)

    objConn.Open  "tablename" , strConnect 

    Set objRS = Server.CreateObject(ADODB.Recordset)

    objRS.Open SQL, objConn, 0 ,1


    ' .. More processing of the other variables .. '

    'Processing / validation done... '
    Response.Write nome & vbCrLf
    Response.Write ID & vbCrLf


     %>

The Get handler works perfectly but if i try to connect to my database i have the error below

    Object required: 'Server

at this line:

 Set objConn = Server.CreateObject(ADODB.Connection)

All the ASP script is inside the body of an HTML page.. I don't find any solution in internet and i haven't many experience in ASP. Someone can help me? Thank you

Upvotes: 0

Views: 1046

Answers (1)

Luke
Luke

Reputation: 527

I Found the error.

I forgot the quotes around ADODB.Connection

  Set objConn = Server.CreateObject("ADODB.Connection")

Upvotes: 1

Related Questions