By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Running both in the IDE and on a remote host

P: n/a
I have an ASP.NET web page accessing a SQL database. I've used VS to build
the app and stored it in the eNPTest02 directory of my localhost on my
development machine. The database is on the web. I've found a way that
works on the web, and I'm trying to get it to also work in debug mode in the
IDE. The "on the web" page and my SQL database are hosted by a third party
(on separate servers).

Since debug mode opens IE and loads my page from localhost, since the
database is located at a web URL, and since my development machine has an
always-on DSL connection, I'm hoping there's a way to get this to work.

As far as I can tell, this may be a Page directive issue: src vs codebehind.
But in either case, I can't get this to work in the IDE.

What am I doing wrong?? I'd appreciate your help.

I've tried 4 Page directive variations, differing in how I reference the vb
page and how I inherit the class:

<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>

None of the above runs in debug mode in the IDE. The last one runs
successfully on the remote host.

codebehind: Won't run in IDE
Won't run on remote host (Parser Error Message: Could not load type)
IDE views are fine

src: Won't run in IDE
Runs on remote host (if I don't refer to localhost directory - as I'd
expect)
Cannot access form design view in IDE
In more detail, here's what happens with each of the 4 variations (Detailed
Code is provided at the end of this post):

'**********
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>

Run in IDE (debug mode)
IE opens, loads eNP02.aspx from localhost, and hangs. (Eventually I get a
page cannot be displayed error.) When I step through the

code, the Page_Load event code executes without throwing an exception.

Run on remote host
Parser Error Message: Could not load type 'eNPTest02.WebForm1'.

When I open the project after it's been closed
The Design and HTML views of eNP02.aspx both display fine.
'**********
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>

Run in IDE (debug mode)
Parser Error Message: Could not load type 'WebForm1'.

Run on remote host
Parser Error Message: Could not load type 'WebForm1'.

When I open the project after it's been closed
The Design and HTML views of eNP02.aspx both display fine.
'**********
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>

Run in IDE (debug mode)
Parser Error Message: The base type 'eNPTest02.WebForm1' does not exist in
the source file 'eNP02.aspx.vb'.

Run on remote host
Parser Error Message: The base type 'eNPTest02.WebForm1' does not exist in
the source file 'eNP02.aspx.vb'.

When I open the project after it's been closed
The file could not be loaded into the Web Forms designer. Please correct
the following error and then try loading it again: The @

Page or @ Control directive contains a src= attribute, which is not
supported in Visual Studio. Make sure all of the classes used in this

page are built or referenced in the project.

I can load the HTML view of eNP02.aspx, but I cannot access the Design view
'**********
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>

Run in IDE (debug mode)
IE opens, loads eNP02.aspx from localhost, and hangs. (Eventually I get a
page cannot be displayed error.) When I step through the

code, the Page_Load event code executes without throwing an exception.

Run on remote host
Runs successfully. The database connection succeeds, and the datagrid
displays all data.

When I open the project after it's been closed
The file could not be loaded into the Web Forms designer. Please correct
the following error and then try loading it again: The @

Page or @ Control directive contains a src= attribute, which is not
supported in Visual Studio. Make sure all of the classes used in this

page are built or referenced in the project.

I can load the HTML view of eNP02.aspx, but I cannot access the Design
view.
codebehind: Won't run on localhost
Won't run on remote host (Parser Error Message: Could not load type)
IDE views are fine

src: Won't run on localhost
Runs on remote host (if I don't refer to localhost directory - as I'd
expect)
Cannot access form design view in IDE
Code:

'eNP02.aspx - the form:
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>

<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>

<body MS_POSITIONING="GridLayout">
<TABLE height="310" cellSpacing="0" cellPadding="0" width="359"
border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="359" height="310">
<form id="Form1" method="post" runat="server">
<TABLE height="342" cellSpacing="0" cellPadding="0" width="298"
border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="56" height="80"></TD>
<TD width="8"></TD>
<TD width="234"></TD>
</TR>
<TR vAlign="top">
<TD height="128"></TD>
<TD colSpan="2">
<asp:Label id="Label1" runat="server" Width="240px"
Height="96px" BorderStyle="Solid">Test 01 Label</asp:Label></TD>
</TR>
<TR vAlign="top">
<TD colSpan="2" height="134"></TD>
<TD>
<asp:DataGrid id="dgCustomers"
runat="server"></asp:DataGrid></TD>
</TR>
</TABLE>
</form>
</TD>
</TR>
</TABLE>
</body>

</HTML>
'eNP02.aspx.vb - the codebehind file
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient

Public Class WebForm1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents dgCustomers As System.Web.UI.WebControls.DataGrid

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim conMain As SqlConnection
Dim sqlCmd As SqlCommand
Dim strConn As String

Try

strConn = ""
strConn = strConn & "Network Library=dbmssocn;"
strConn = strConn & "Password=myPassword;"
strConn = strConn & "User ID=myUser;"
strConn = strConn & "Initial Catalog=myDB;"
strConn = strConn & "Data Source=000.000.000.000;"

conMain = New SqlConnection(strConn)
sqlCmd = New SqlCommand("SELECT FirstName, LastName FROM
eNPCustomers", conMain)
conMain.Open()

Dim rdrCustomers As SqlDataReader = sqlCmd.ExecuteReader

dgCustomers.DataSource = rdrCustomers
dgCustomers.DataBind()

conMain.Close()

Label1.Text = "Codebehind Works"

Catch ex As Exception
Response.Write(ex.ToString)

End Try

End Sub

End Class
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Jeff,

I would start over with a new page. In VS.Net create a new web page, call
it eNP03.Aspx when it asks for a name. Now your code behind and your .aspx
page will be properly hooked up. Next copy everything but the @Page
directive in eNP02, paste this into eNP03 overwriting everything but the
@Page directive. Next copy all the code from the eNP02.aspx.vb file and
paste it into eNP03.aspx.vb. Then change this line:

Public Class WebForm1

Back to:

Public Class eNP03

Which is what it was before you copied the code in the .vb file. Now you
know you are setup right. Set eNP03.aspx as your start page by right
clicking on it and selecting that menu item. Now run the project. If you
still have a problem then you probably have something setup wrong with your
IIS or .Net Framework setup. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Jeff" <je*********@eNetPortals.com> wrote in message
news:sI****************@newsread3.news.atl.earthli nk.net...
I have an ASP.NET web page accessing a SQL database. I've used VS to build the app and stored it in the eNPTest02 directory of my localhost on my
development machine. The database is on the web. I've found a way that
works on the web, and I'm trying to get it to also work in debug mode in the IDE. The "on the web" page and my SQL database are hosted by a third party (on separate servers).

Since debug mode opens IE and loads my page from localhost, since the
database is located at a web URL, and since my development machine has an
always-on DSL connection, I'm hoping there's a way to get this to work.

As far as I can tell, this may be a Page directive issue: src vs codebehind. But in either case, I can't get this to work in the IDE.

What am I doing wrong?? I'd appreciate your help.

I've tried 4 Page directive variations, differing in how I reference the v b page and how I inherit the class:

<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>

None of the above runs in debug mode in the IDE. The last one runs
successfully on the remote host.

codebehind: Won't run in IDE
Won't run on remote host (Parser Error Message: Could not load type)
IDE views are fine

src: Won't run in IDE
Runs on remote host (if I don't refer to localhost directory - as I'd
expect)
Cannot access form design view in IDE
In more detail, here's what happens with each of the 4 variations (Detailed Code is provided at the end of this post):

'**********
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>

Run in IDE (debug mode)
IE opens, loads eNP02.aspx from localhost, and hangs. (Eventually I get a page cannot be displayed error.) When I step through the

code, the Page_Load event code executes without throwing an exception.

Run on remote host
Parser Error Message: Could not load type 'eNPTest02.WebForm1'.

When I open the project after it's been closed
The Design and HTML views of eNP02.aspx both display fine.
'**********
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>

Run in IDE (debug mode)
Parser Error Message: Could not load type 'WebForm1'.

Run on remote host
Parser Error Message: Could not load type 'WebForm1'.

When I open the project after it's been closed
The Design and HTML views of eNP02.aspx both display fine.
'**********
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>

Run in IDE (debug mode)
Parser Error Message: The base type 'eNPTest02.WebForm1' does not exist in the source file 'eNP02.aspx.vb'.

Run on remote host
Parser Error Message: The base type 'eNPTest02.WebForm1' does not exist in the source file 'eNP02.aspx.vb'.

When I open the project after it's been closed
The file could not be loaded into the Web Forms designer. Please correct
the following error and then try loading it again: The @

Page or @ Control directive contains a src= attribute, which is not
supported in Visual Studio. Make sure all of the classes used in this

page are built or referenced in the project.

I can load the HTML view of eNP02.aspx, but I cannot access the Design view

'**********
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>

Run in IDE (debug mode)
IE opens, loads eNP02.aspx from localhost, and hangs. (Eventually I get a page cannot be displayed error.) When I step through the

code, the Page_Load event code executes without throwing an exception.

Run on remote host
Runs successfully. The database connection succeeds, and the datagrid
displays all data.

When I open the project after it's been closed
The file could not be loaded into the Web Forms designer. Please correct
the following error and then try loading it again: The @

Page or @ Control directive contains a src= attribute, which is not
supported in Visual Studio. Make sure all of the classes used in this

page are built or referenced in the project.

I can load the HTML view of eNP02.aspx, but I cannot access the Design
view.
codebehind: Won't run on localhost
Won't run on remote host (Parser Error Message: Could not load type)
IDE views are fine

src: Won't run on localhost
Runs on remote host (if I don't refer to localhost directory - as I'd
expect)
Cannot access form design view in IDE
Code:

'eNP02.aspx - the form:
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>

<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>

<body MS_POSITIONING="GridLayout">
<TABLE height="310" cellSpacing="0" cellPadding="0" width="359"
border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="359" height="310">
<form id="Form1" method="post" runat="server">
<TABLE height="342" cellSpacing="0" cellPadding="0" width="298" border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="56" height="80"></TD>
<TD width="8"></TD>
<TD width="234"></TD>
</TR>
<TR vAlign="top">
<TD height="128"></TD>
<TD colSpan="2">
<asp:Label id="Label1" runat="server" Width="240px"
Height="96px" BorderStyle="Solid">Test 01 Label</asp:Label></TD>
</TR>
<TR vAlign="top">
<TD colSpan="2" height="134"></TD>
<TD>
<asp:DataGrid id="dgCustomers"
runat="server"></asp:DataGrid></TD>
</TR>
</TABLE>
</form>
</TD>
</TR>
</TABLE>
</body>

</HTML>
'eNP02.aspx.vb - the codebehind file
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient

Public Class WebForm1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents dgCustomers As System.Web.UI.WebControls.DataGrid

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim conMain As SqlConnection
Dim sqlCmd As SqlCommand
Dim strConn As String

Try

strConn = ""
strConn = strConn & "Network Library=dbmssocn;"
strConn = strConn & "Password=myPassword;"
strConn = strConn & "User ID=myUser;"
strConn = strConn & "Initial Catalog=myDB;"
strConn = strConn & "Data Source=000.000.000.000;"

conMain = New SqlConnection(strConn)
sqlCmd = New SqlCommand("SELECT FirstName, LastName FROM
eNPCustomers", conMain)
conMain.Open()

Dim rdrCustomers As SqlDataReader = sqlCmd.ExecuteReader

dgCustomers.DataSource = rdrCustomers
dgCustomers.DataBind()

conMain.Close()

Label1.Text = "Codebehind Works"

Catch ex As Exception
Response.Write(ex.ToString)

End Try

End Sub

End Class

Nov 19 '05 #2

P: n/a
Thanks Ken -

I tried your suggestion with the same result. And while there may be
something amiss with IIS, I don't think that's causing this problem(?).

I've tested the aspx - vb page link and it seems to be working. I think
I've narrowd the problem down to something having to do with databinding.

So once again, I've posted a new thread (Databinding a SQLDataReader to a
DataGrid control), since the 'Subject' no longer applies. I'd appreciate
any further suggestions you can offer.

- Jeff
"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Jeff,

I would start over with a new page. In VS.Net create a new web page, call
it eNP03.Aspx when it asks for a name. Now your code behind and your ..aspx page will be properly hooked up. Next copy everything but the @Page
directive in eNP02, paste this into eNP03 overwriting everything but the
@Page directive. Next copy all the code from the eNP02.aspx.vb file and
paste it into eNP03.aspx.vb. Then change this line:

Public Class WebForm1

Back to:

Public Class eNP03

Which is what it was before you copied the code in the .vb file. Now you
know you are setup right. Set eNP03.aspx as your start page by right
clicking on it and selecting that menu item. Now run the project. If you
still have a problem then you probably have something setup wrong with your IIS or .Net Framework setup. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Jeff" <je*********@eNetPortals.com> wrote in message
news:sI****************@newsread3.news.atl.earthli nk.net...
I have an ASP.NET web page accessing a SQL database. I've used VS to build
the app and stored it in the eNPTest02 directory of my localhost on my
development machine. The database is on the web. I've found a way that
works on the web, and I'm trying to get it to also work in debug mode in

the
IDE. The "on the web" page and my SQL database are hosted by a third

party
(on separate servers).

Since debug mode opens IE and loads my page from localhost, since the
database is located at a web URL, and since my development machine has an always-on DSL connection, I'm hoping there's a way to get this to work.

As far as I can tell, this may be a Page directive issue: src vs

codebehind.
But in either case, I can't get this to work in the IDE.

What am I doing wrong?? I'd appreciate your help.

I've tried 4 Page directive variations, differing in how I reference the v b
page and how I inherit the class:

<%@ Page Language="vb" codebehind="eNP02.aspx.vb"
autoeventwireup="false" Inherits="eNPTest02.WebForm1"%>
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false" Inherits="WebForm1"%>
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>

None of the above runs in debug mode in the IDE. The last one runs
successfully on the remote host.

codebehind: Won't run in IDE
Won't run on remote host (Parser Error Message: Could not load type)
IDE views are fine

src: Won't run in IDE
Runs on remote host (if I don't refer to localhost directory - as I'd
expect)
Cannot access form design view in IDE
In more detail, here's what happens with each of the 4 variations

(Detailed
Code is provided at the end of this post):

'**********
<%@ Page Language="vb" codebehind="eNP02.aspx.vb" autoeventwireup="false" Inherits="eNPTest02.WebForm1"%>

Run in IDE (debug mode)
IE opens, loads eNP02.aspx from localhost, and hangs. (Eventually I get a
page cannot be displayed error.) When I step through the

code, the Page_Load event code executes without throwing an exception.

Run on remote host
Parser Error Message: Could not load type 'eNPTest02.WebForm1'.

When I open the project after it's been closed
The Design and HTML views of eNP02.aspx both display fine.
'**********
<%@ Page Language="vb" codebehind="eNP02.aspx.vb"
autoeventwireup="false" Inherits="WebForm1"%>

Run in IDE (debug mode)
Parser Error Message: Could not load type 'WebForm1'.

Run on remote host
Parser Error Message: Could not load type 'WebForm1'.

When I open the project after it's been closed
The Design and HTML views of eNP02.aspx both display fine.
'**********
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="eNPTest02.WebForm1"%>

Run in IDE (debug mode)
Parser Error Message: The base type 'eNPTest02.WebForm1' does not exist

in
the source file 'eNP02.aspx.vb'.

Run on remote host
Parser Error Message: The base type 'eNPTest02.WebForm1' does not exist

in
the source file 'eNP02.aspx.vb'.

When I open the project after it's been closed
The file could not be loaded into the Web Forms designer. Please correct the following error and then try loading it again: The @

Page or @ Control directive contains a src= attribute, which is not
supported in Visual Studio. Make sure all of the classes used in this

page are built or referenced in the project.

I can load the HTML view of eNP02.aspx, but I cannot access the Design

view


'**********
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>

Run in IDE (debug mode)
IE opens, loads eNP02.aspx from localhost, and hangs. (Eventually I get a
page cannot be displayed error.) When I step through the

code, the Page_Load event code executes without throwing an exception.

Run on remote host
Runs successfully. The database connection succeeds, and the datagrid
displays all data.

When I open the project after it's been closed
The file could not be loaded into the Web Forms designer. Please

correct the following error and then try loading it again: The @

Page or @ Control directive contains a src= attribute, which is not
supported in Visual Studio. Make sure all of the classes used in this

page are built or referenced in the project.

I can load the HTML view of eNP02.aspx, but I cannot access the Design
view.
codebehind: Won't run on localhost
Won't run on remote host (Parser Error Message: Could not load type)
IDE views are fine

src: Won't run on localhost
Runs on remote host (if I don't refer to localhost directory - as I'd
expect)
Cannot access form design view in IDE
Code:

'eNP02.aspx - the form:
<%@ Page Language="vb" src="eNP02.aspx.vb" autoeventwireup="false"
Inherits="WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>

<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>

<body MS_POSITIONING="GridLayout">
<TABLE height="310" cellSpacing="0" cellPadding="0" width="359"
border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="359" height="310">
<form id="Form1" method="post" runat="server">
<TABLE height="342" cellSpacing="0" cellPadding="0"

width="298"
border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="56" height="80"></TD>
<TD width="8"></TD>
<TD width="234"></TD>
</TR>
<TR vAlign="top">
<TD height="128"></TD>
<TD colSpan="2">
<asp:Label id="Label1" runat="server" Width="240px"
Height="96px" BorderStyle="Solid">Test 01 Label</asp:Label></TD>
</TR>
<TR vAlign="top">
<TD colSpan="2" height="134"></TD>
<TD>
<asp:DataGrid id="dgCustomers"
runat="server"></asp:DataGrid></TD>
</TR>
</TABLE>
</form>
</TD>
</TR>
</TABLE>
</body>

</HTML>
'eNP02.aspx.vb - the codebehind file
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient

Public Class WebForm1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents dgCustomers As System.Web.UI.WebControls.DataGrid

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim conMain As SqlConnection
Dim sqlCmd As SqlCommand
Dim strConn As String

Try

strConn = ""
strConn = strConn & "Network Library=dbmssocn;"
strConn = strConn & "Password=myPassword;"
strConn = strConn & "User ID=myUser;"
strConn = strConn & "Initial Catalog=myDB;"
strConn = strConn & "Data Source=000.000.000.000;"

conMain = New SqlConnection(strConn)
sqlCmd = New SqlCommand("SELECT FirstName, LastName FROM
eNPCustomers", conMain)
conMain.Open()

Dim rdrCustomers As SqlDataReader = sqlCmd.ExecuteReader

dgCustomers.DataSource = rdrCustomers
dgCustomers.DataBind()

conMain.Close()

Label1.Text = "Codebehind Works"

Catch ex As Exception
Response.Write(ex.ToString)

End Try

End Sub

End Class


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.