This topic is locked
[SOLVED]

 Duplicate Record

6/25/2019 3:36:38 PM
ASPRunner.NET General questions
D
DebZ author

Hello,
Trying to test to see if a record already exists in the table for projects (field name is ProjectNu) before adding record. This won't compile, and I assume I have a or multiple syntax errors.

If someone could help, it would be appreciated.
Thanks,
Deb
Table is dbo.ProjectCloseOut and the field with the Project Number is ProjectNu. I'm guessing I have the quotes all wrong. ?
//** Check if specific record exists ****

string strSQLExists = "select * from dbo.ProjectCloseOut where ProjectNu='$values["ProjectNu"]';

XVar rsExists = CommonFunctions.db_query(strSQLExists, null);

XVar data = CommonFunctions.db_fetch_array(rsExists);

if(data)

{

return false; // if record exists do something

}

else

{

return true; // if dont exist do something else

}
// Place event code here.

// Use "Add Action" button to add code snippets.
return true;

T
Tim 6/25/2019

Try this:
string strSQLExists = "select * from dbo.ProjectCloseOut where ProjectNu='" + values["ProjectNu"].ToString() + "'";
Tim

D
DebZ author 6/25/2019

Thank you so much! That worked like a charm <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=88048&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />



Try this:
string strSQLExists = "select * from dbo.ProjectCloseOut where ProjectNu='" + values["ProjectNu"].ToString() + "'";
Tim