L
Lasse Edsvik
Hello
Im trying to do a simple page with data from my local sql server, and page
just shows up blank...... I created a stored procedure with SELECT * FROM
Employees...... returns 9 rows in QA
whats wrong?
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new
SqlConnection("server=localhost;uid=sa;pwd=;database=northwind");
SqlCommand cmd = new SqlCommand("EmployeesList", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
DataGrid1.DataSource = cmd.ExecuteReader(Commandbehaviour.CloseConnection);
DataGrid1.DataBind();
// Put user code to initialize the page here
}
#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
}
}
then:
<%@ Page language="c#" Codebehind="Webform1.aspx.cs" AutoEventWireup="false"
Inherits="dbtest.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server" />
</form>
</body>
</HTML>
Im trying to do a simple page with data from my local sql server, and page
just shows up blank...... I created a stored procedure with SELECT * FROM
Employees...... returns 9 rows in QA
whats wrong?
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new
SqlConnection("server=localhost;uid=sa;pwd=;database=northwind");
SqlCommand cmd = new SqlCommand("EmployeesList", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
DataGrid1.DataSource = cmd.ExecuteReader(Commandbehaviour.CloseConnection);
DataGrid1.DataBind();
// Put user code to initialize the page here
}
#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
}
}
then:
<%@ Page language="c#" Codebehind="Webform1.aspx.cs" AutoEventWireup="false"
Inherits="dbtest.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server" />
</form>
</body>
</HTML>