Firstly - concatenating user input in strings like that leaves you vulnerable to SQL Injection Attacks. Use Parameterized Queries instead - it's difficult to find documentation relevent to VB6 these days but I did find this
Parameterized Update query in VB6 - Visual Basic (Classic) - Tek-Tips[
^]
Your error message is probably being generated because txtBirthdate.Text is not in a valid date format. This could well be fixed by using a Parameterised Query.
You should probably also not be using all those conversions - if you get the txtBirthdate.Text bit correct and use a Parameterised query that part of the query becomes
Select DATEDIFF(YEAR,@Birthdate,103),
Select DATEDIFF(YEAR,?,103),
Edit - corrected the code, I forgot that VB6 cannot handle named parameters.
The next thing to note is that the SQL function DATEDIFF is expecting date or time expressions
not
the
varchar
that you are using with
,CONVERT(varchar,V_ISSUEDATE,103)) from VISITOR_MASTER_NEW
See
DATEDIFF (Transact-SQL) - SQL Server | Microsoft Docs[
^]
If
V_ISSUEDATE
is a date or datetime column type on your database then there is no need at all for the
CONVERT
and if
V_ISSUEDATE
is not a date or datetime column type on your database then you need to change your database. Always use the correct column type for the data that will be stored in it
EDIT:
I have just spotted another major problem - You can't refer to a column in a recordset by name if you don't give it a name in the first place! Your SQL code should read
Select DATEDIFF(YEAR,CONVERT(datetime,?,V_ISSUEDATE,103) AS V_AGE from VISITOR_MASTER_NEW