This topic is locked

Events - After record Added - Check if specific record exists

7/13/2009 11:47:30 AM
ASPRunner.NET General questions
T
thecomputerguy author

when i add this event the webpage gets an error on this line: I have the latest ASPRunner.net build 2497.

All I want to doo is search table2 to see if a value from table1 exist.

If not i want to add a record in table2 with the value from table1 It should pretty simple!

Erro:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30002: Type 'Query' is not defined.
Source Error:
Line 17: 'Check if specific record exists

Line 18:

Line 19: Dim query As Query = New Query()

Line 20:

Line 21: query.WHERE("AnyColumn", e["columnToLookFor"].ToString())
Thank you,
Andrew

Sergey Kornilov admin 7/13/2009

Andrew,
please use the following:

Dim query As Query = New Query(AnyTable.Schema)
query.WHERE("AnyColumn", "valueToLookFor")
Dim count As Integer
Try

count = query.GetRecordCount()

If count > 0 Then

'if record exists do something

Else

'if dont exist do something else

End If

Finally

End Try


Replace "AnyTable" with your actual table name, "AnyColumn" with the

column you'd like to check and "valueToLookFor" with the actual value

so it looks like this for table Customers:

Dim query As Query = New Query(Customers.Schema)
query.WHERE("CustomerID", 4)
Dim count As Integer
Try

count = query.GetRecordCount()

If count > 0 Then

'if record exists do something

Else

'if dont exist do something else

End If

Finally

End Try
T
thecomputerguy author 7/14/2009

Sergey, I send you the project as this will not work... I get an error saying that

Dim query As Query = New Query()

Compiler Error Message: BC30002: Type 'Query' is not defined.
So when you clear this event it does not clear it.... please advice...
Thank you,
Andrew

Andrew,

please use the following:

Dim query As Query = New Query(AnyTable.Schema)
query.WHERE("AnyColumn", "valueToLookFor")
Dim count As Integer
Try

count = query.GetRecordCount()

If count > 0 Then

'if record exists do something

Else

'if dont exist do something else

End If

Finally

End Try


Replace "AnyTable" with your actual table name, "AnyColumn" with the

column you'd like to check and "valueToLookFor" with the actual value

so it looks like this for table Customers:

Dim query As Query = New Query(Customers.Schema)
query.WHERE("CustomerID", 4)
Dim count As Integer
Try

count = query.GetRecordCount()

If count > 0 Then

'if record exists do something

Else

'if dont exist do something else

End If

Finally

End Try
T
thecomputerguy author 7/15/2009

New compile was made to fix this. thank you Sergey and TEAM Great job!

Sergey, I send you the project as this will not work... I get an error saying that

Dim query As Query = New Query()

Compiler Error Message: BC30002: Type 'Query' is not defined.
So when you clear this event it does not clear it.... please advice...
Thank you,
Andrew