Dean has told you how to get it to work but warning.... DataViews are much much much slower than DataReaders.
http://learnasp.com/freebook/learn/dbopen.aspx shows you the correct DataReader code along with error trapping. All you have to do is change the ID. ddlFlightNo.DataTextField = "flightno" (you do not need both you only need the .DataValueField if there is a different field (like a numeric id corresponiding to the text) http://learnasp.com/freebook/learn/vb_firstlib.aspx shows you how to populate Dropdowns in a really reusable way. On 11/22/05, Real_Guy <[EMAIL PROTECTED]> wrote: > Hi All, > Im a beginner in ASP.Net. > I tried to display data in drop down list from data base. > The code is like this : > > Dim sqlString As String > Dim DS As New DataSet() > Dim myConn As SqlConnection > Dim myDataAdapter As SqlDataAdapter > Dim myDataView As New DataView() > > 'opening connection > myConn = New > sqlConnection("server=192.168.100.101;database=autoqplex;uid=sa;pwd=sa") > myDataAdapter = New SqlDataAdapter(sqlString, myConn) > > 'myConn.Open() > myDataAdapter.Fill(DS) 'here is the error > 'myConn.Close() > > ddlFlightNo.DataSource = DS.Tables("mflightno").DefaultView > ddlFlightNo.DataValueField = "flightno" > ddlFlightNo.DataTextField = "flightno" > ddlFlightNo.DataBind() > > but when i try to run it, an error occured (ExecuteReader: CommandText > property has not been initialized) > > Can you tell me how to fix this problem > > > many thanks in advance > > > > > > > > > > ________________________________ > YAHOO! GROUPS LINKS > > > Visit your group "AspNetAnyQuestionIsOk" on the web. > > To unsubscribe from this group, send an email to: > [EMAIL PROTECTED] > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. > > ________________________________ > ------------------------ Yahoo! Groups Sponsor --------------------~--> Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
