Results 1 to 4 of 4

Thread: What's wrong with this code?

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954

    What's wrong with this code?

    I am trying to bind multiple tables to one dataset and use these ables to fill select boxes. But the following code is not working.

    Code:
    <%@ Page Language="VB" Debug="true" %>
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Data.SQLClient" %>
    <script runat="server">
    
        'Page load event of the web page.
                 'This is similar to the Form_Load event in VB.'
             Protected Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load
                Dim id as string
                id = request.querystring("locID")
                Dim myConnection as New SQLConnection("Server=DSHSDBLCY4000A;Database=NIS;UID=inet_nis_user;PWD=**********;")
                myConnection.Open
        
               Dim strSQL as String
               strSQL = "select SYS_Main.LocationID, SYS_Main.Org, SYS_Main.Region from SYS_Main where SYS_Main.LocationID = " & chr(39) & id & chr(39) & "; Select * from SYS_Monitors where SYS_Monitors.LocationID = " & chr(39) & id & chr(39) & ";"
               
                Dim DS as New DataSet()
                Dim cnAdapter as new SqlDataAdapter(strSQL, myConnection)
                cnAdapter.Fill(DS)
               
               'Dim myCommand as New SQLCommand(strSQL,myConnection)
               'Dim adapter As New SqlDataAdapter()
               
               'Dim myDataReader as SQLDataReader
               'myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
        
               'dgMain.DataSource = myDataReader
               'dgMain.DataBind()
        
               myConnection.Close()
               
               With ID1
                .DataSource = DS.Tables("SYS_Main")
                .DataValueField = "LocationID"
                .DataTextField = "PriorityTitle"
                .DataBind()
               End With
    
              With ID2
                .DataSource = DS.Tables("SYS_Monitors")
                .DataValueField = "Quantity"
                .DataTextField = "Status"
                .DataBind()
              End With           
    
      
             End Sub
        
    </script>
    <html>
    <head>
        <title>Summary for # <%=request.querystring("locID")%></title>
    </head>
    <body>
    <form runat="server">
        <p>
            <asp:Dropdownlist id="ID1" 
                           Runat="server" 
                           EnableViewState="False" >
            </asp:Dropdownlist>
            <asp:Dropdownlist id="ID2" 
                           Runat="server" 
                           EnableViewState="False" >
            </asp:Dropdownlist>
            <!--<asp:DataGrid id="dgMain" Runat="server" Width="184px" Height="38px"></asp:DataGrid>-->
        </p>
       </form>
    </body>
    </html>
    Last edited by brianh; Jun 9th, 2003 at 09:49 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width