How to use the DataTable.Select?

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

    How to use the DataTable.Select?

    Hi,

    I am trying to build a Login web form. I have one TextBoxAccount, and one
    Password1 in the web form.
    And the database table is User. No

    DataRow[] FRow;
    FRow = DS.Tables["User"].Select("UsrID= @TextBoxAccount .Text and PassWd=
    @Password1.Valu e " );
    if (FRow != null )
    {
    LabelAccount.Te xt="Identified! ";
    LabelPassword.T ext="Identified !";
    }
    else
    {
    LabelAccount.Te xt =" Unknown";
    LabelPassword.T ext =" Unknown";
    }

    However, it is not working as I planed.
    Would someone give me some advice?
    Thanks.

    Jason


  • AinO

    #2
    Re: How to use the DataTable.Selec t?

    Hi,

    Without testing myself, i suspect the Select method does not fill in the
    values of your parameters ;

    I suggest you build your filter expression first and then pass it,

    string selectString = "UsrID=" + TextBoxAccount. Text + " and PassWd=" +
    Password1.Value ;
    FRow = DS.Tables["User"].Select(selectS tring);
    ....

    Also you might consider to build a try catch block around your Select to
    catch possible exceptions ;
    they do help a lot in clarifying a problem (not specifically this problem)

    Hope this helps,

    AinO.

    "Jason Huang" <JasonHuang8888 @hotmail.com> wrote in message
    news:#ngGY9WcFH A.2424@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi,
    >
    > I am trying to build a Login web form. I have one TextBoxAccount, and one
    > Password1 in the web form.
    > And the database table is User. No
    >
    > DataRow[] FRow;
    > FRow = DS.Tables["User"].Select("UsrID= @TextBoxAccount .Text and PassWd=
    > @Password1.Valu e " );
    > if (FRow != null )
    > {
    > LabelAccount.Te xt="Identified! ";
    > LabelPassword.T ext="Identified !";
    > }
    > else
    > {
    > LabelAccount.Te xt =" Unknown";
    > LabelPassword.T ext =" Unknown";
    > }
    >
    > However, it is not working as I planed.
    > Would someone give me some advice?
    > Thanks.
    >
    > Jason
    >
    >[/color]


    Comment

    • Jason Huang

      #3
      Re: How to use the DataTable.Selec t?

      Thanks!
      I think I missed the "'" before and after the TextBoxAccount. Text!

      "AinO" <no.spam@please .com> ¼¶¼g©ó¶l¥ó·s»D: QnRre.121061$7Y 6.6841443@phobo s.telenet-ops.be...[color=blue]
      > Hi,
      >
      > Without testing myself, i suspect the Select method does not fill in the
      > values of your parameters ;
      >
      > I suggest you build your filter expression first and then pass it,
      >
      > string selectString = "UsrID=" + TextBoxAccount. Text + " and PassWd=" +
      > Password1.Value ;
      > FRow = DS.Tables["User"].Select(selectS tring);
      > ...
      >
      > Also you might consider to build a try catch block around your Select to
      > catch possible exceptions ;
      > they do help a lot in clarifying a problem (not specifically this problem)
      >
      > Hope this helps,
      >
      > AinO.
      >
      > "Jason Huang" <JasonHuang8888 @hotmail.com> wrote in message
      > news:#ngGY9WcFH A.2424@TK2MSFTN GP09.phx.gbl...[color=green]
      >> Hi,
      >>
      >> I am trying to build a Login web form. I have one TextBoxAccount, and
      >> one
      >> Password1 in the web form.
      >> And the database table is User. No
      >>
      >> DataRow[] FRow;
      >> FRow = DS.Tables["User"].Select("UsrID= @TextBoxAccount .Text and
      >> PassWd=
      >> @Password1.Valu e " );
      >> if (FRow != null )
      >> {
      >> LabelAccount.Te xt="Identified! ";
      >> LabelPassword.T ext="Identified !";
      >> }
      >> else
      >> {
      >> LabelAccount.Te xt =" Unknown";
      >> LabelPassword.T ext =" Unknown";
      >> }
      >>
      >> However, it is not working as I planed.
      >> Would someone give me some advice?
      >> Thanks.
      >>
      >> Jason
      >>
      >>[/color]
      >
      >[/color]


      Comment

      Working...