
January 25th, 2004, 09:22 PM
|
|
Registered User
|
|
Join Date: Dec 2003
Location: My own mind
Posts: 11
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Unable to attach to ASP.NET process...?
Hi, I have the book "Programming in C#" and I am learning about ASP.NET right now. I am working on a webform example in the book and it says to install IIS and FP Server Extensions. I have installed IIS v5.1 and the front page server extensions, however when I run my code (typed verbatim from the book) it starts an Internet Explorer page with URL: http://localhost/WebForm1/HelloWeb.aspx and displays nothing then I get an error message box stating "Unable to attach to ASP.NET process (typically aspnet_wp.exe)"
I am a definite newbie with all of this and was wondering why I can't seem to get ASP.NET or webforms to work properly.
Here is the code I have in Borland C# Builder (Although a simple webform with hello world and a <% %> time statement also fails):
PHP Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebForm1
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
// Data members used for initializing page_load with
// data from database.
private System.Data.SqlClient.SqlConnection myConnection;
private System.Data.DataSet myDataSet;
private System.Data.SqlClient.SqlCommand myCommand;
private System.Data.SqlClient.SqlDataAdapter dataAdapter;
protected System.Web.UI.WebControls.RadioButtonList rbl1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
{
string connectionString = "server=(local)\\NetSDK;" +
"Trusted_Connection=yes; database=northwind";
myConnection = new System.Data.SqlClient.SqlConnection(
connectionString);
myConnection.Open();
// Create the dataset and set Case Sensitive Property
myDataSet = new System.Data.DataSet();
myDataSet.CaseSensitive = true;
// Create the SqlCommand onject and assign the
// connection and the select statement
myCommand = new System.Data.SqlClient.SqlCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = "SELECT ShipperID, CompanyName FROM Shippers";
// create the dataAdapter object and pass in the
// SqlCommand object and establish the data mappings
dataAdapter = new System.Data.SqlClient.SqlDataAdapter();
dataAdapter.SelectCommand=myCommand;
dataAdapter.TableMappings.Add("Table", "Shippers");
dataAdapter.Fill(myDataSet);
// Set up the properties for the rbl1
rbl1.RepeatLayout =
System.Web.UI.WebControls.RepeatLayout.Flow;
rbl1.DataTextField = "CompanyName";
rbl1.DataValueField = "ShipperID";
// Set the datasource and use default view of shippers table
rbl1.DataSource = myDataSet.Tables["Shippers"].DefaultView;
rbl1.DataBind();
// Set one to be default selected
rbl1.Items[0].Selected = true;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
|