Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Im trying to put a table on my form to display a list of results from a plans table on my database.

 

However, I need to know how I get it to the screen.

 

Do I put the code for accessing the data in the code section or in the HTML section? Also how is best to put it into a table?

 

Here is my code so far:

Dim oConn As SqlConnection
       Dim oComm As SqlCommand
       Dim oReader As SqlDataReader
       Dim sSQL As String
       Dim sConn As String
       Dim strDept As String

       strDept = Request.QueryString("dept_id")

       sSQL = "SELECT * "
       sSQL += "FROM Plans where department_id = " & strDept
       sConn = ConfigurationSettings.AppSettings("ConnectionString")

       oConn = New SqlConnection(sConn)
       oConn.Open()

       oComm = New SqlCommand(sSQL, oConn)
       oReader = oComm.ExecuteReader()

**********writing the results to a table  I expect should go here *********

       oConn.Close()

 

Thanks!

Posted

or you can use the asp.net datagrid which has the format of a table. very simple. in the body of your html you stick:

 

<asp:datagrid id="dgresults" runat="server" />

 

then instead of this:

 

oReader = oComm.ExecuteReader()

 

put:

 

dgresults.datsource = oComm.executereader()

dgresults.databind ()

 

 

you dont even need the datareader object in this case.

You can not get ye flask.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...