Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - question
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

question

 Post Reply Post Reply
Author
papercut19 View Drop Down
Newbie
Newbie


Joined: 23 February 2006
Location: Belize
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote papercut19 Quote  Post ReplyReply Direct Link To This Post Topic: question
    Posted: 24 February 2006 at 1:08pm
hy everyone,
 
i've connect to a database with asp. whit the info i take from it i'm trying 2 make a drop down menu. problem is that my drop down menu is empty
 
i'll put in my cod if any one can see what's wrong please tell me
 
<html>
 <body>
<script language="jscript" runat="server">
  
   function Pag_load( sender : Object, events : EventArgs )
   {
    if ( !IsPostBack )
    {
     var dataBaseConnection : OleDbConnection = new
      OleDbConnection( ConfigurationSettings.AppSettings(
     "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Philip\Mijn documenten\Stage\test2\Sportdienst 2005.mdb" ) );
    
     var queryString : System.String =
      "SELECT Categorienummer, Categorienaam FROM Categorie";
    
     dataBaseConnection.Open();
     
     var dataBaseCommand : OleDbCommand =
      new OleDbCommand( queryString, dataBaseConnection );
     
     var dataReader = dataBaseCommand.ExecuteReader();
    
     // while we read a row from result of
     // query, add first item to drop down list
     while ( dataReader.Read() )
      nameList.Items.Add( dataReader.GetString(0) +
     ", " + dataReader.GetString(1) );
     
    // close database connection
    dataBaseConnection.Close();
   }
   else
   {
    dataGrid.DataSource = GetData();
    dataGrid.DataBind();
   }
  } // end Page_load
  
  // Read a database and return the DataView
  function GetData() : ICollection
  {
    var set : DataSet = new DataSet();
   
    //establish a connection, and query the database
    var dataBaseConnection: OleDbConnection = new
     OleDbConnection( ConfigurationSettings.AppSettings(
   "ConnectionString" ) );
   
    var categorie : int = nameList.SelectedIndex + 1;
   
    var queryString : String =
     "SELECT Achternaam, Voornaam, Straat + Nr, "+
   "Postnummer, Gemeente FROM Categorie " +
   "WHERE (Categorienummer = " + categorie + ")";
   
    var dataBaseCommand : OleDbCommand =
     new OleDbCommand( queryString, dataBaseConnection );
   
    var dataAdapter : OleDbDataAdapter =
     new OleDbDataAdapter( dataBaseCommand );
   
    dataAdapter.Fill( set );
   
    // close database connection
    dataBaseCommand.Connection.Close();
   
    var dataView : DataView = new DataView( set.Tables[ 0 ] );
    dataView.Sort = "Title";
   
    return dataView;
  } // end GetData
  
</script>
<form runat="server">
 <Header:ImageHeader id = "head" runat = "server">
 </Header:ImageHeader>
 <br />
 
 Authors:
 <asp:DropDownList ID="nameList" runat="server"
  Width="158px" Height="22px">
 </asp:DropDownList>
 <asp:Button ID="button" Text="select" runat="server">
 </asp:Button>
 <p>
  <asp:DataGrid ID="dataGrid" runat="server">
  </asp:DataGrid>
 </p>
 
 </form>
 </body>
</html>
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.