Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2005

    ASP.NET & Access

    Hey there chaps =)

    Basically im new to ASP.NET... infact im pretty new to programming on a whole and im having a bit of trouble digesting the books Ive bought inorder to learn.

    The way Im now trying to learn is by having an actually program/script idea in my head that Im wanting to code and then learning from that code.

    Basically Im wanting to make a directory-esq script which takes the details I have from an access database, and catergorises it alphabetically. And then potentially add sub-catergories.

    So for example... Ive got the first colum in my db as
    United States

    Now... I can display them... I get that far. But I cant set the order theyre dispayed in to make them alphabetical unless I do it to the actually db file manually.

    The code Im using is
    <%@ Import Namespace="" %>
    <%@ Import Namespace="System.Data.Oledb" %>
    <script language="vb" runat="server">
    Sub Page_Load(Sender as object, E as EventArgs)
    Dim objConnection as OleDbConnection
    Dim objCommand As OleDbDataAdapter
    Dim strConnect As String
    Dim strCommand As String
    Dim DataSet1 As New DataSet

    strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;"
    strConnect += "Data Source=C: (WHEREVER)"
    strConnect += "Persist Security Info=False"

    strCommand = "Select PlaceName From Places"
    objConnection = New OleDbConnection(strConnect)
    objCommand = New OleDbDataAdapter(strCommand, objConnection)
    objCommand.Fill(DataSet1, "Places")
    End Sub
    <title>blah blah blah</title>
    <ASP: DataGrid ID="DataGrid1" RunAt="server" />
    I would like to make these alphabetical on load up so 'A' would be at the top and 'Z' at the bottom. But I cant find how to do this.

    .... I would also like the place name to be a hyperlink which would like to another page which displays additional info from the same DB file.

    So the db would look something like:
    Column 1 | Column 2
    England | This is a place bordered by Scotland and Wales
    Holland | The capital of Holland is Amsterdam
    United States | Mickey Mouse lives in the US
    France | French people like their food
    Greece | Beware the Greeks...

    So.... You goto a page and it show the Counties in alphabetical order, you can then click on the Country name and be taken to another seperate page that Dispays the place name again and this time also the info in column 2

    .......... Thats All!! hehehe. Is there anyone here who is willing to point me in the right direction? Im not looking for an easy ride as Im wanting to learn. Please dont tell me to 'Google it' as I learn better by being able to bounce questions off of other people. Im just asking for a helping hand.

    Many Thank in advance
    Turn My Text - íspuǝıɹɟ ʞooqǝɔɐɟ ɹnoʎ ǝzɐɯɐ puɐ ǝsnɟuoɔ

    Computer Game Cheats & Codes

  2. #2
    Join Date
    Apr 2004

    strCommand = "Select PlaceName From Places"


    strCommand = "Select PlaceName From Places Order by PlaceName"

    That should hopefully do it let me know if that doesnt work.

  3. #3
    Join Date
    Apr 2004
    Basically when retrieving data via the SQL command you need to tell the db to return the data in a format sorted by the Field Placename

    You can also do

    strCommand = "Select PlaceName From Places Order by PlaceName ASC"


    strCommand = "Select PlaceName From Places Order by PlaceName DESC"

    for ascending or descending order respectively. I believe it defaults to ascending if you dont specify.

  4. #4
    Join Date
    Apr 2004
    For your second question, you can probably have a second column in your db with the country information. Name it something like 'information'. On the second page you can run a command like

    DIM countryName
    countryName = request.form("passedName")

    strCommand = "Select PlaceName, Information From Place where PlaceName=" & countryName

    Here countryName is a variable, you`ll need to pass that variable onto the second page from the first page. You can do that via hidden fields, though since im not well versed at all in im not sure if im saying the right thing or not. (im gonna start learning in a few days ) Basically on the previous page when someone clicks the link say England, then the value England should be passed on as a hidden field or query string or something to the next page which then stores it in the variable countryName. Here the variable being passed from the previous page is called passedName, and the variable used locally in page 2 is called countryName.

    if you are passing by query string then the command will be

    countryName = request.querystring("passedName")

    I see you are doing this in, im only slightly experienced in VBscript so my code may be wrong.

    I hope i helped, feel free to ask me anytime via MSN at [email protected]
    Last edited by ahmedaf; 07-16-2005 at 05:28 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