I created a function to retrieve a value based on the session.
The function will take the session value and return the value I want
The problem is : it works with some rows, but it's not with others
The table I have contains more than 2000 rows
This is my function.
Public Shared Function GetUserNational(ByVal NationalID As Integer) As Int64
Const sql = "SELECT Applicant_ID FROM DIP_Applicant where NationalID = @NationalID"
Using con As New SqlConnection(ConfigurationManager.ConnectionStrings("mydbConnectionString").ConnectionString)
Using cmd = New SqlCommand(sql, con)
Using reader = cmd.ExecuteReader()
If reader.HasRows Then
Dim count As Int64 = reader.GetInt32(0)
My table contain Applicant_Id type int and primary key contain also National_Id as nvarchar(50)
in my website the user should enter his or her national Id and i will return the applicant Id
the same call the same queriy
for example I have already national_Id "102323232" when I enter it in my text box it shows me the applicant Id
but when I give anouther Id like "100555666"; it return 0 but the value should not be zero-
it's already in the table and it's not 0