wooikeim Posted March 15, 2007 Share Posted March 15, 2007 I had make a connection to the database. What i want now is to display the subject id in a label called lblsubject_id.--------------------------------------------------------------------------------------------------------------------------------------------------Dim mycommand as sqlDataAdapter= new sqlDataAdapter("Select subject_id from tutor where tutor_id = '"& lbluser.text &"' ", myConnection)b4 this what i do is show in datagrid, but now i want it to be display in label. Dim ds as new dataset() mycommand.fill(ds,"tutor") DataGrid1.datasource=ds.tables("tutor").defaultview Datagrid1.databind()what shud i do here? Link to comment Share on other sites More sharing options...
aspnetguy Posted March 15, 2007 Share Posted March 15, 2007 instead do the following Dim mycommand As SqlCommand = new SqlCommand("query",myConnection)myConnection.Open()Dim dr As SqlDataReader = mycommand.ExecuteReader()While dr.Read lblsubject_id.Text = dr.Item("ColumnName")End Whiledr.Close()myConnection.Close() Link to comment Share on other sites More sharing options...
wooikeim Posted March 15, 2007 Author Share Posted March 15, 2007 instead do the followingDim mycommand As SqlCommand = new SqlCommand("query",myConnection)myConnection.Open()Dim dr As SqlDataReader = mycommand.ExecuteReader()While dr.Read lblsubject_id.Text = dr.Item("ColumnName")End Whiledr.Close()myConnection.Close() Dim mycommand As SqlCommand = new SqlCommand("query",myConnection)is "query" fix? or what? Link to comment Share on other sites More sharing options...
aspnetguy Posted March 15, 2007 Share Posted March 15, 2007 no replace "query" with your query "Select subject_id from tutor where tutor_id = '"& lbluser.text &"' " Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now