Avatar of angelsofgrace2006
angelsofgrace2006
Flag for Portugal

asked on 

Why is Response.Write giving me this error ?

Hi,

I'm building this module for a site I'm building in C#/ASP.NET

The code follows my signature.

I'm getting an error on line:

Response.Write(IDPost);

saying:

"The name Response does not exist in the current context".

I'm by no means a C# guru, but this really beats me :(

Any help would be appreciated.

Warm Regards,
Mário Gamito

--

using System.Xml;
using CommunityServer.Components;
using System.Collection.Generic;
using System.Text;
using System.Xml;
using System.IO;
using System.Data;
using System.data.SqlClient;

namespace BookDetector
{

    public class BookDetectorModule : ICSModule
    {

        public BookDetectorModule()
        {
        }

        public void Init(CSApplication csa, XmlNode node)
        {
            csa.PostPostUpdate += new CSPostEventHandler(csa_PostPostUpdate);
        }

        private void csa_PostUserUpdate(User user, CSEventArgs e)
        {

           int IDPost = -1;

           SqlConnection myConn = new SqlConnection("Data Source=192.168.1.50"; Initial Catalog=mydb; User=123; Password=123");

          try
          {
            myConn.Open();
           SqlCommand myCommand = new SqlCommand("SELECT MAX(PostID) from dbo.Posts", myConn);
           IDPost = (int)myCommand.ExecuteScalar();
         }
         finally
         {
           if (myConn != null)
           {
            myConn.Close();
           }
         }

         Response.Write(IDPost);

        }
    }

}
.NET ProgrammingC#

Avatar of undefined
Last Comment
burakiewicz

8/22/2022 - Mon