Databinding

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Neel

    #1

    Databinding

    I would like to bind a custom sql statement such as

    sSqlStmt = "SELECT PgmSchID, SessionBegDate" & " - "
    & "SessionEndDate " & " - " & "SessionTim e" & " - "
    & "SessionDay AS PgmSessions" _
    & " FROM ProgramScheduli ng WHERE PgmID
    = '" + ddlPgm1.Selecte dItem.Value + "'"

    below is my code which i am not able to bind
    OleRdr = clsDBAccess.Exe cuteReader(Comm andType.Text,
    sSqlStmt)
    ddlPgmSess1.Dat aSource = OleRdr
    ddlPgmSess1.Dat aTextField = "PgmSession s"
    ddlPgmSess1.Dat aValueField = "PgmSchID"
    ddlPgmSess1.Dat aBind()
    ddlPgmSess1.Ite ms.Insert(0, "Select
    Session")
    ddlPgmSess1.Sel ectedIndex = 0

    help me out
    Neel
  • Carol Torkko

    #2
    Databinding

    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[color=blue]
    >-----Original Message-----
    >I would like to bind a custom sql statement such as
    >
    > sSqlStmt = "SELECT PgmSchID, SessionBegDate" & " - "
    >& "SessionEndDate " & " - " & "SessionTim e" & " - "
    >& "SessionDay AS PgmSessions" _
    > & " FROM ProgramScheduli ng WHERE PgmID
    >= '" + ddlPgm1.Selecte dItem.Value + "'"
    >
    >below is my code which i am not able to bind
    >OleRdr = clsDBAccess.Exe cuteReader(Comm andType.Text,
    >sSqlStmt)
    > ddlPgmSess1.Dat aSource = OleRdr
    > ddlPgmSess1.Dat aTextField = "PgmSession s"
    > ddlPgmSess1.Dat aValueField = "PgmSchID"
    > ddlPgmSess1.Dat aBind()
    > ddlPgmSess1.Ite ms.Insert(0, "Select
    >Session")
    > ddlPgmSess1.Sel ectedIndex = 0
    >
    >help me out
    >Neel
    >.
    >[/color]

    Comment

    Working...