Jump to content

displaying data in label


wooikeim

Recommended Posts

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

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

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()

Dim mycommand As SqlCommand = new SqlCommand("query",myConnection)is "query" fix? or what?
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...