PDA

View Full Version : Triggers in windows application


solostar***
02-20-2004, 02:51 AM
hello

I have created a windows application with visual c++ 6.0 which connects to a database.
The application executes SQL queries and I want to set some triggers or the insert, update and delete queries.
However, Where should i place my triggers?

sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=s",sDriver,sFile);
TRY
{
CDatabase ComboDatabase;
// Open the database
ComboDatabase.Ope(NULL,false,false,sDsn);

// Build the SQL statement
SqlCommand = "INSERT INTO BandSetting "
"VALUES('" + str25 + "'" ",'" + str1 + "'" ",'" + str2 + "'"
",'" + str3 + "'" ",'" + str4 + "'" ",'"+ str5 + "'" ",'"+ str6 + "'" ",'" + str7 + "'" ",'" + str8 + "'" ",'"+ str9 + "'" ",'" + str10 + "'" ",'" + str11 + "'" ",'"+ str12 + "'" ",'" + str13 + "'" ",'" + str14 + "'" ",'" + str15 + "'" ",'" + str16 + "'" ",'" + str17 + "'" ",'"+ str18 + "'" ",'" + str19 + "'" ",'" + str20 + "'" ",'"+ str21 + "'" ",'" + str22 + "'" ",'" + str23 + "'" ", + str24 + "'" ")" ;

ComboDatabase.ExecuteSQL(SqlCommand);
// Close the database
ComboDatabase.Close();
}

where do i put the trigger???
hope you guys can help me out on this! thanks (^_^!!)

Strike
02-20-2004, 03:57 AM
Please don't cross-post.

DNAunion2000
02-21-2004, 12:12 PM
solostar: where do i put the trigger???

Triggers are usually stored in the database itself.

They are much like stored procedures in that they are both code stored in the database; however, stored procedures are explicitly called and are free to implement just about any logic, while triggers are automatically fired by the DBMS whenever their corresponding table event (INSERT, UPDATE, or DELETE) occurs (and therefore, the logic that triggers implement should be limited to being related to such events).