Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

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/FBrender.aspx" -->
<asp:Label ID="VraagID" runat="server" visible="False"></asp:Label><br>
<asp:Label ID="CaseID" runat="server" visible="False"></asp:Label><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.ConfigurationSettings.AppSettings("connectionstring")

Sub Page_Load
  Dim QuestionID = VraagID.text
  Dim intCaseID = CaseID.text
  Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)

  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.SqlCommand = New System.Data.SqlClient.SqlCommand(StrSql, sqlConnection)

  sqlConnection.Open
  Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

  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
0
seloh
Asked:
seloh
  • 2
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
You haven't said what the problem is !! Are you getting an error ? Or is it simply not showing anything ?
0
 
selohAuthor Commented:
Sorry!
There's nothing showing up ... I get an empty page!
0
 
samtran0331Commented:
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.

0
 
Carl TawnSystems and Integration DeveloperCommented:
You also don't appear to have set up databinding anywhere. You have a call to Page.DataBind, but you aren't actually binding your dataset to a control (like a datagrid for example).
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now