Hi kunal,
I think you want to check for an existence of a user. Try the following (its
in vb with sql classes, but your can figure out how to do it in C# with your
oledb source)
Since you want to check, and only check, you need to read, so you can use a
DataReader.
Dim dr as sqlDataReader
Dim cm as new sqlCommand("SELECT UserName FROM tbUser", cn)
cn.open()
dr = cm.ExecuteReader()
do while dr.Read
if txtUsername.Text = CStr(dr("UserName")) then -- In vb, CStr casts the
value to String
' User found
end if
loop
Dont forget to close your datareader and dispose your connection when your
are done.
Ps. This code was not tested
"Kunal Sen" <Kunal
(E-Mail Removed)> wrote in message
news:072DFA3C-D264-4F2B-B56F-(E-Mail Removed)...
>I am creating a login screen wherein only certain users are granted
> permission. The names of those users,are copied into a dataset using
> dataadapter.Then the dataview is used.
>
> But the problem here is that the "Dv.Count" always evaluates ..to 0. Hence
> whenever I enter the valid names "Invalid User" is prompted on the screen
>
> I have writen the code below.
>
> OleDbDataAdapter dAdap1 = new OleDbDataAdapter("SELECT ..[EMPLOYEE ID]
> FROM
> EMPLOYEE;",con1);
>
> dAdap1.Fill(DtSet);
>
> Dv.Table=DtSet.Tables["EMPLOYEE"];
>
> Dv.RowFilter.CompareTo(txtLogin.Text);
>
> if(Dv.Count==0)
>
> {
>
> txtLogin.Text="Invalid User";
>
> }
>
> Kindly suggest,
>
>