Databinding

  • Thread starter Thread starter Neel
  • Start date Start date
N

Neel

I would like to bind a custom sql statement such as

sSqlStmt = "SELECT PgmSchID, SessionBegDate" & " - "
& "SessionEndDate" & " - " & "SessionTime" & " - "
& "SessionDay AS PgmSessions" _
& " FROM ProgramScheduling WHERE PgmID
= '" + ddlPgm1.SelectedItem.Value + "'"

below is my code which i am not able to bind
OleRdr = clsDBAccess.ExecuteReader(CommandType.Text,
sSqlStmt)
ddlPgmSess1.DataSource = OleRdr
ddlPgmSess1.DataTextField = "PgmSessions"
ddlPgmSess1.DataValueField = "PgmSchID"
ddlPgmSess1.DataBind()
ddlPgmSess1.Items.Insert(0, "Select
Session")
ddlPgmSess1.SelectedIndex = 0

help me out
Neel
 
Hi Neel,
I am assuming you are using the DataReader object in
ADO.Net. I can't tell what control you are trying to bind
to. If my assumption is correct that you are using the
DataReader control, you can only read once in a forward
direction.

If you are looking to load a control with data that you
use for reading in your app, then use the DataReader
control by reading through each record and loading the
contents into the control. In other words, there is no
binding with the DataReader object.

If you are truly looking to bind for updating, etc., then
you should be using the Fill method of the dataadapter to
load the data into a table in a dataset object. You can
then find your control to the table in the dataset. This
is a disconnected environment, so if you are looking to
update the database, you will need to execute the Update
method of the dataadapter after you have preloaded the
various command properties of the dataadapter.

I hope this helps.

Carol
 
Back
Top