Question Sql Table Adapter

Th4x3

Member
Joined
Jul 31, 2010
Messages
5
Programming Experience
1-3
He im creating a user login form where my users put in a nickname and the TableAdapter searches for the matching password and returns it to my program,

I made a little code to convert the tabulardata to an single string but when i use it i get a blank msgbox where the password should be...

This is the VB code:
VB.NET:
        Dim DataConnection As TDTableAdapters.UsersTableAdapter = New TDTableAdapters.UsersTableAdapter
                
                Dim dt As System.Data.DataTable = DataConnection.GetLoginCredentials(Nickname.Text)

                For Each dr As System.Data.DataRow In dt.Rows
                    returnValue = dr("Password").ToString()
                Next

This is the SQL String used by the TableAdadapter
VB.NET:
SELECT        Password
FROM            Users
WHERE        (Nickname LIKE @Nickname)

And when i used this SQL code because thought that the select values where the problem:
VB.NET:
SELECT        Password, Nickname
FROM            Users
WHERE        (Nickname LIKE @Nickname)

I got this error code on the line: Dim dt As System.Data.DataTable = DataConnection.GetLoginCredentials(Nickname.Text)

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

Did somebody encounter this problem before or just knows the solution to my problems?

Thanks in advance,
Milan v. Dijck
 
If you are looking for the username as is then replace the LIKE with = ... otherwise if you want to see if e.g. username contains the parameter value change the sql code DO the following:

VB.NET:
SELECT        Password, Nickname
FROM            Users
WHERE        (Nickname LIKE '%' + @Nickname + '%')

But i guess you need this change:

VB.NET:
SELECT        Password, Nickname
FROM            Users
WHERE        (Nickname [B]=[/B] @Nickname)
 

Latest posts

Back
Top