seloh
asked on
Display data from database
Hi ... I'm new to ASP.net and I'm trying to create an extra page for an existing application.
The page is supposed to retrieve some information form a database and display it!
I have the following!
Feedback.aspx
=====
<!-- #include file = "../scripts/include/FBrend er.aspx" -->
<asp:Label ID="VraagID" runat="server" visible="False"></asp:Labe l><br>
<asp:Label ID="CaseID" runat="server" visible="False"></asp:Labe l><br>
<HTML>
<HEAD>
<TITLE>Feedback</TITLE>
</HEAD>
<BODY>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
<TR>
<TD VALIGN=TOP>
<asp:Label ID="FeedBack" runat="server"></asp:Label >
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
=====
FBrender.aspx
=====
<%@ Page Language="VB" %>
<%@ import Namespace="System.Drawing" %>
<script runat="server">
Public connectionstring As String = System.Configuration.Confi gurationSe ttings.App Settings(" connection string")
Sub Page_Load
Dim QuestionID = VraagID.text
Dim intCaseID = CaseID.text
Dim sqlConnection As System.Data.SqlClient.SqlC onnection = New System.Data.SqlClient.SqlC onnection( connection String)
Dim StrSql As String = "SELECT Feedback FROM RI_CaseA WHERE Case_ID = '"& intCaseID &"' AND VraagID = '"& QuestionID &"' ORDER BY AntwoordVolgorde"
Dim sqlCommand As System.Data.SqlClient.SqlC ommand = New System.Data.SqlClient.SqlC ommand(Str Sql, sqlConnection)
sqlConnection.Open
Dim dataReader As System.Data.SqlClient.SqlD ataReader = sqlCommand.ExecuteReader(S ystem.Data .CommandBe havior.Clo seConnecti on)
if dataReader.Read then
FeedBack.text = dataReader("Feedback")
End if
dataReader.Close
dataReader = Nothing
sqlConnection.Close
page.databind
end sub
</script>
<html>
<head>
</head>
<body>
</body>
</html>
=====
The SQL-statement
[SELECT Feedback
FROM RI_CaseA
WHERE Case_ID = '"& intCaseID &"' AND VraagID = '"& QuestionID &"'
ORDER BY AntwoordVolgorde]
retrieves several records and I have to display them all.
I use following syntax to call the page
http://..../feedback.aspx?CaseID=1&VraagID=2
I'm probably forgetting something really simple!!
Thnx in advance
The page is supposed to retrieve some information form a database and display it!
I have the following!
Feedback.aspx
=====
<!-- #include file = "../scripts/include/FBrend
<asp:Label ID="VraagID" runat="server" visible="False"></asp:Labe
<asp:Label ID="CaseID" runat="server" visible="False"></asp:Labe
<HTML>
<HEAD>
<TITLE>Feedback</TITLE>
</HEAD>
<BODY>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
<TR>
<TD VALIGN=TOP>
<asp:Label ID="FeedBack" runat="server"></asp:Label
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
=====
FBrender.aspx
=====
<%@ Page Language="VB" %>
<%@ import Namespace="System.Drawing"
<script runat="server">
Public connectionstring As String = System.Configuration.Confi
Sub Page_Load
Dim QuestionID = VraagID.text
Dim intCaseID = CaseID.text
Dim sqlConnection As System.Data.SqlClient.SqlC
Dim StrSql As String = "SELECT Feedback FROM RI_CaseA WHERE Case_ID = '"& intCaseID &"' AND VraagID = '"& QuestionID &"' ORDER BY AntwoordVolgorde"
Dim sqlCommand As System.Data.SqlClient.SqlC
sqlConnection.Open
Dim dataReader As System.Data.SqlClient.SqlD
if dataReader.Read then
FeedBack.text = dataReader("Feedback")
End if
dataReader.Close
dataReader = Nothing
sqlConnection.Close
page.databind
end sub
</script>
<html>
<head>
</head>
<body>
</body>
</html>
=====
The SQL-statement
[SELECT Feedback
FROM RI_CaseA
WHERE Case_ID = '"& intCaseID &"' AND VraagID = '"& QuestionID &"'
ORDER BY AntwoordVolgorde]
retrieves several records and I have to display them all.
I use following syntax to call the page
http://..../feedback.aspx?CaseID=1&VraagID=2
I'm probably forgetting something really simple!!
Thnx in advance
You haven't said what the problem is !! Are you getting an error ? Or is it simply not showing anything ?
ASKER
Sorry!
There's nothing showing up ... I get an empty page!
There's nothing showing up ... I get an empty page!
Are you going to use the FBrender.aspx code on other pages? Wondering why you separated the pages.
Have you tried putting the FBrender.aspx code on the same page as Feedback.aspx? Does it pull data then?
Dont see the System.Data.SQLClient namespace reference anywhere either....it could be that.
You dimmed your datareader and called the namespace, but it isn't in the page directive.
Include files are getting pretty much obsolete in .NET also...if you're practicing good OOP, then SQL and datasets should be in a separate class file or even separate project that gets referenced in your interface project.
If you're moving from ASP to ASP.Net, I would suggest moving to Visual Studio.Net as well.
I hate to say it...but Microsoft VS.Net is the best .Net tool.... .Net is fairly different from ASP and although you can use different IDE's and notepad for ASP, you're making it a lot harder on yourself not using VS.Net.
Plus right now, VS.Net 2005 is in beta2 with a "Go Live" guarantee from MS. And it is free to order the full app on DVD. Also, the express version is free for download.
Have you tried putting the FBrender.aspx code on the same page as Feedback.aspx? Does it pull data then?
Dont see the System.Data.SQLClient namespace reference anywhere either....it could be that.
You dimmed your datareader and called the namespace, but it isn't in the page directive.
Include files are getting pretty much obsolete in .NET also...if you're practicing good OOP, then SQL and datasets should be in a separate class file or even separate project that gets referenced in your interface project.
If you're moving from ASP to ASP.Net, I would suggest moving to Visual Studio.Net as well.
I hate to say it...but Microsoft VS.Net is the best .Net tool.... .Net is fairly different from ASP and although you can use different IDE's and notepad for ASP, you're making it a lot harder on yourself not using VS.Net.
Plus right now, VS.Net 2005 is in beta2 with a "Go Live" guarantee from MS. And it is free to order the full app on DVD. Also, the express version is free for download.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.