1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

CS0103: The name 'response' does not exist

Discussion in 'C#' started by josephamr, Apr 12, 2012.

  1. #1
    Hello,

    I am new on c#, Iam trying to read data from MSSQL table using single .aspx file.
    now I am facing this Error CS0103.

    Compiler Error Message:
    CS0103: The name 'response' does not exist in the current context.

    <%@ Page Language="C#" Debug="true" %><%@ Import Namespace="System" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    
    <script runat="server">
    
    
            class DataReader_SQL
            {
                    
                    [STAThread]
                    public static void Main(string[] args)
                    {
                            
                            try
                            {
                            SqlConnection thisConnection = new SqlConnection(@"Network Library=DBMSSOCN;Data Source=MyserverIP,1433;database=DBname;
                                    User id=DBuser;Password=DBpass;");
                                    thisConnection.Open();
                            SqlCommand thisCommand = thisConnection.CreateCommand();
                            thisCommand.CommandText = "SELECT Num1, Num2 FROM z_TestSite";
                             SqlDataReader thisReader = thisCommand.ExecuteReader();
                                    while (thisReader.Read())
                                    {
                                    Console.WriteLine(thisReader["Num1"], thisReader["Num2"]);
                                            }
                                    thisReader.Close();
                                    thisConnection.Close();
                            }
                            catch (SqlException e)
                            {
                                    Console.WriteLine(e.Message);
                            }
                            
                    }
            }
    
    </script>
    PHP:
    Any Help Please ? :eek:
     
    josephamr, Apr 12, 2012 IP
  2. raspms

    raspms Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i also face this problem..thanks for sharing..
     
    raspms, Apr 17, 2012 IP
  3. Scarrfo

    Scarrfo Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I believe you need to use response.write and not console.write. Console.write is for desktop applications, generally for quick debugging.

    Console.WriteLine(thisReader["Num1"], thisReader["Num2"]);

    should be

    Response.Write(thisReader["Num1"], thisReader["Num2"]);
    same with
    Console.WriteLine(e.Message);
     
    Scarrfo, May 5, 2012 IP
  4. strike2867

    strike2867 Member

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #4
    What in the world is that? You state it is php code, but then the code is in asp.net, but actually trying to create a console app.
     
    strike2867, May 14, 2012 IP