Sunday, February 19, 2012

Ambiguous match found.

Does anyone know what this error means?

Ambiguous match found.

i'm using sql server 2000

here is my code

Dim con As SqlConnection = New SqlConnection

con.ConnectionString = _
"Data Source=localhost;" + _
"Initial Catalog=registeruser;" + _
"User ID=int422;" + _
"Password=int422"

Dim cmd As SqlCommand = New SqlCommand

cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT salt,hash FROM users WHERE login_id = '" + user.Text + "'"

Dim rdr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

con.Open()

Dim salt, hash As String

While rdr.Read()

If user.Text = rdr.Item("login_id").ToString() Then

salt = rdr.Item("salt").ToString()
hash = rdr.Item("hash").ToString()

End If

End While

con.Close()

Label1.Text = salt

End SubAre you sure that SQL statement is what is really getting called in your code ?

rdr.Item("login_id") wouldn't exist in the data reader as you have only selected "salt" and "hash".

<MindReading
My guess is, you haven't posted the SQL statement you are really using, you are using something with a JOIN in it and you are doing a SELECT * in there.
In your result set from the SQL statement, you have two columns called "login_id" so the dataReader doesn't know which one to reference.

If you change your SQL statement to only return the fields you want, you shouldn't have the problem

i.e. SELECT salt,hash, users.login_id FROM users INEER JOIN Blah etc etc

</MindReading

No comments:

Post a Comment