Question Check if user not exists in sql?

sebasjuh

Member
Joined
Dec 6, 2007
Messages
13
Programming Experience
Beginner
Hello,

I have a little problem (I think).
I have this code to check if a user (the list of users i'll get from the active directory) exists in the SQL table.

VB.NET:
'Read from SQL
SQLStr = "SELECT * FROM table WHERE username='" & dir.Properties("Name").Value & "'"

SQLConn.ConnectionString = ConnString 'Set the Connection String
SQLConn.Open() 'Open the connection

SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
SQLCmd.CommandText = SQLStr 'Sets the SQL String
SQLdr = SQLCmd.ExecuteReader 'Gets Data

While SQLdr.Read() 'While Data is Present
    SQLfinal = SQLdr("username")
    msgbox(SQLfinal)
End While

SQLdr.Close() 'Close the SQLDataReader
SQLConn.Close() 'Close the connection

If the selected user exists in the SQL table I get the msgbox. But i don't want the know the users who are in the SQL table I want the list of users who don't exists in the SQL table.

But I found out if the user doesn't exists the scripts dont come to:
While SQLdr.Read()
because there is nothing to read.

How can I get the names of those who aren't exists in the SQL table?
 
Hello.

Arr...If you want a list with suers which are not in the database, the first question is "How do you know they are there?". I mean, you need a list of users to check back if the user exists in the database. What users are we talking about? Self-Made, Windows...???

Bobby
 
The list of all users i'll get from Active Directory.
And when a user login a record get's written into the SQL.

So I want to check if there is no record from a user in the SQL so I can see that he has never logged in.
 
Back
Top