M
mark.irwin
Hello,
I have a namespace created for handling my database connections.
This works fine when used with an aspx page that contains the code.
When i try to create a codebehind page (seperate from my namespace) I
cant get it all to work together.
test.aspx (code)
-------------------------------------------------------------------
<%@ Import namespace="My_Stuff" %>
<%@ assembly src="conn.vb" %>
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>
<script runat="server">
sub Page_Load
dim strSQL as string
dim cmdSQL As SqlCommand 'execute SQL query
dim rdrData As SqlDataReader 'holds SQL query data
strSQL = "SELECT TOP 10 * FROM [some table]"
cmdSQL = New SqlCommand (strSQL , db_connect.open)
rdrData= cmdSQL.ExecuteReader()
grd_subMas.DataSource = rdrData
grd_subMas.DataBind()
rdrData.close()
db_connect.close()
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<asp
ataGrid ID="grd_subMas" runat="server" />
</body>
</html>
------------------------------------------------------------------
conn.vb (code)
-------------------------------------------------------------------
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Configuration
NameSpace My_Stuff
Public Class db_connect
Public Shared strConn as string =
ConfigurationSettings.AppSettings([connection key])
Public Shared MyConn as New SQLConnection(strConn)
Public Shared Function open
MyConn.Open()
return MyConn
End Function
Public Shared Function close
MyConn.close()
end function
end class
end NameSpace
-------------------------------------------------------------------
The above configuration works fine.
i would like to take the Page_Load and put it into a code-behind page.
Is there a way?
I have a namespace created for handling my database connections.
This works fine when used with an aspx page that contains the code.
When i try to create a codebehind page (seperate from my namespace) I
cant get it all to work together.
test.aspx (code)
-------------------------------------------------------------------
<%@ Import namespace="My_Stuff" %>
<%@ assembly src="conn.vb" %>
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>
<script runat="server">
sub Page_Load
dim strSQL as string
dim cmdSQL As SqlCommand 'execute SQL query
dim rdrData As SqlDataReader 'holds SQL query data
strSQL = "SELECT TOP 10 * FROM [some table]"
cmdSQL = New SqlCommand (strSQL , db_connect.open)
rdrData= cmdSQL.ExecuteReader()
grd_subMas.DataSource = rdrData
grd_subMas.DataBind()
rdrData.close()
db_connect.close()
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<asp
</body>
</html>
------------------------------------------------------------------
conn.vb (code)
-------------------------------------------------------------------
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Configuration
NameSpace My_Stuff
Public Class db_connect
Public Shared strConn as string =
ConfigurationSettings.AppSettings([connection key])
Public Shared MyConn as New SQLConnection(strConn)
Public Shared Function open
MyConn.Open()
return MyConn
End Function
Public Shared Function close
MyConn.close()
end function
end class
end NameSpace
-------------------------------------------------------------------
The above configuration works fine.
i would like to take the Page_Load and put it into a code-behind page.
Is there a way?