|
-
January 2nd, 2000, 12:38 PM
#1
Can any body Help me !!! Creating Triggers in VB 6.0
I need to create trigger on a table which should fire when any of the column is modified. I am using Visual Basic 6.0 as IDE and Access 8.0 as my database. MSDN online speaks about creating triggers but I am not aware how and where to create the triggers, I mean code window. Can someone helm me and tell me in detail how do I create triggers in VB using Data View Window or any other way.
Thanks
Gibli
:-)
-
January 3rd, 2000, 03:11 AM
#2
Re: Can any body Help me !!! Creating Triggers in VB 6.0
AFAIK triggers are a SQLServer "thing" only.
thus, you need a client that can communicate to SQL Server. I suggest you use ISQL/w or Enterprise manager that comes with SQL server 6 and above.
To create a trigger:
CREATE TRIGGER mytrigger on yourtablename
FOR INSERT, UPDATE
AS
...write your SQLCode here
-
January 3rd, 2000, 08:43 AM
#3
Re: Can any body Help me !!! Creating Triggers in VB 6.0
Thanks for the response.
I saw in MSDN library which talks about creating triggers in VB 6 for the Access database, they have shown the e.g. of NWIND.mdb. But the MSDN doesn't tell me where exactly I have to code this trigger. MSDN says you have to open Data View WIndow
Database
Tables
Right click on the table you want to create a trigger but I didn't see any option available for me to create a trigger.
Can anybody help me!!! The company where I am working presently is using MS-Access 8.0 as back-end amd VB6 as front-end. I can't use SQL server 6.0. I know that triggers can be implemented easily in SQL server 6 and oracle. But I am not aware how to implement triggers. I need the following feature :
Whenever a user tries to update TABLE A, a record should be inserted in TABLE B
which will tell me me what field in the TABLE A has be changed. How can I implement this functionality using VB6 and Access Database. I would appreciate it if somebody can explain it with an example.
Thanks,
Sri
-
January 3rd, 2000, 12:03 PM
#4
Re: Can any body Help me !!! Creating Triggers in VB 6.0
Triggers are not available in Access. You may be able to emulate triggers partially by using cascading updates/deletes. The rest has to be done inside your program with code and transactions.
-
January 3rd, 2000, 12:10 PM
#5
Re: Can any body Help me !!! Creating Triggers in VB 6.0
I think you can create a sub/function that writes records in table B, you can call this sub/function passing records changed everytime you code the update.
I tried this to create a log file in access database, every operation calls a function that saves in a table the operation done. I'm sorry but i cant' write code now.
private sub updatebutton_click()
.
.
.
' here the code to update
.
.
trigger (records_changed)
end sub
.
.
.
.
public sub trigger(records_changed as ....)
.
.
.
'here the code to write data in table B
.
.
.
end sub
Something over there is coding....
... and you don't know!
-
January 3rd, 2000, 05:09 PM
#6
Re: Can any body Help me !!! Creating Triggers in VB 6.0
How will we know which field has been modified before updating? Is there any good solution for my problem. Can anybody put me in the right direction? I appreciate you people are trying to help. Give me example please!!!!!
Thanks,
Sri
-
January 4th, 2000, 06:22 AM
#7
Re: Can any body Help me !!! Creating Triggers in VB 6.0
You can put a string equal to"" at beginning and everytime a textbox associated to a field changes it can set the string to a value, a.e.:
private sub text1_change()
'here you can also add code to test if already
'changed, something like the function instr to
'serach if mystring has 1
mystring = mystring & "1"
'it says the first field was changed so need
'to be updated
end sub
In the update button you search in mystring what fields are changed.
Something over there is coding....
... and you don't know!
-
January 4th, 2000, 07:51 AM
#8
Re: Can any body Help me !!! Creating Triggers in VB 6.0
I will try it out.
Thanks,
Gibli
-
January 5th, 2000, 10:04 PM
#9
Re: Can any body Help me !!! Creating Triggers in VB 6.0
Thank you guy Lonely Wolf U have been very helpful.
- Gibli
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|