Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,156,218 members, 7,829,360 topics. Date: Thursday, 16 May 2024 at 05:02 AM

Ado.net And Vb.net Question. - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Ado.net And Vb.net Question. (1103 Views)

Asp.net And Php Which Is Better / Tutorial: How To Return Html In Json Response Using Asp.net And Jquery / Post Ur Vb 6.0 Questions Here (2) (3) (4)

(1) (Reply) (Go Down)

Ado.net And Vb.net Question. by AjaraEwuro: 1:35pm On Jun 04, 2009
I want to pass values dynamically to a dropdownlist from a result of an ado.net connection.


        Dim ftname, fttown As String
        ftname = Session("town")
        fttown = Session("street")

        Dim conn, rs1, sql, dbread
        conn = CreateObject("ADODB.Connection")
        conn.Provider = "Microsoft.Jet.OLEDB.4.0"
        conn.Open(Server.MapPath("maps1_old.mdb"))
        rs1 = Server.CreateObject("ADODB.recordset")
        sql = "SELECT DISTINCT a, x, y FROM maps111 where name LIKE '" & ftname & "%' AND town ='" & fttown & "' "
        rs1.Open(sql, conn)

     

        Dim rname, rx, ry As String


        On Error Resume Next
        rs1.MoveFirst()
        Do While Not rs1.eof
            rname = rs1("a")
            rx = rs1("x")
            ry = rs1("y")


       
            dlist.Items.Add(rname)

            rs1.MoveNext()

       
        Loop

        conn.Close()
        rs1.Close()
        conn = Nothing
        rs1 = Nothing

    End Sub


This code only sows the dropdownliast but doesnt populate with the result.
Re: Ado.net And Vb.net Question. by BigStar1(m): 3:47pm On Jun 04, 2009
try to refresh the recordset.
and let me know what happen
Re: Ado.net And Vb.net Question. by AjaraEwuro: 4:02pm On Jun 04, 2009
nothing happen bro!
Re: Ado.net And Vb.net Question. by Kobojunkie: 4:55pm On Jun 04, 2009
You forgot to Bind the Datasource to your dropdownlist.

Best you learn to work with DataReaders and DataSets

You return a DataSet and just bind the DataTable to your list object eg

'Databind the DataReader to the listbox Web control

lstFAQs.DataSource = objDR
lstFAQs.DataBind()
Re: Ado.net And Vb.net Question. by AjaraEwuro: 5:58pm On Jun 04, 2009
@Kobo

I am using an oledb connection, does this use datareaders and datasets?

U may be right there, because my approach was using recordset which is classic ASP.
Re: Ado.net And Vb.net Question. by Kobojunkie: 7:41pm On Jun 04, 2009
Even if you are not going to use DataReader, Dataset or even tables or any other of that sort, you still need to call Databind on your dropdownlist

Look at this example

http://www.4guysfromrolla.com/ASPScripts/PrintPage.asp?REF=%2Fwebtech%2F073101-1.shtml
Re: Ado.net And Vb.net Question. by AjaraEwuro: 7:54pm On Jun 04, 2009
@kobo

You are now officially I_laugh's wife - thanks.
Re: Ado.net And Vb.net Question. by BigStar1(m): 8:56am On Jun 05, 2009
So, is the problem solved?
Re: Ado.net And Vb.net Question. by AjaraEwuro: 9:01am On Jun 05, 2009
@Big Star.

Yes, it is solved. Kobojunkie's name is now KoboGenius.


And she is now I_laugh's wife.

(1) (Reply)

Inspiring Your World!! Facepassion. / Should I keep on writing codes and seeking admission at the same time? / Mobile Bulk Sms Application

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.