when to call addrecord() in data entry form using DTC's?

friends  i want to create a simple data-entry form using
DTC's. suppose this form is based on a table(emp) containing
 one primary field(ename). i'm using 1 DTC recordset (recordset1,which
is based on sql-->select ename from emp where 1=2, since i
don't want to display any existing record, it has to be only
 a data-entry form and not updateable form.), 1 DTC textbox(ename)
 and a DTC button(save) which i want to use for saving the record.
now my problem is where and when to call addrecord()  method?

i've achieved this goal by using a separate button by clicking which i
call this method. but i want this to happen automatically. so that
i only have to call updaterecord() when i press "save" button.

looking forward for your helping hand.

Who is Participating?
spruce22Connect With a Mentor Commented:

Yes I see how inefficient that would be.  But let me say this, and tell if I'm off somwhere.  Right now you say you've accomplished the task by adding an extra button to call .AddRecord().  So when the button is pressed, the client page must call the server and add a new record.  It seems like the same thing as the inefficient AfterUpdate idea I had earlier.  Can you take a different approach to the situation? Instead of calling updaterecord() when the Save button is pressed - why don't you submit all the information from the form to an .asp page which calls both .AddRecord and .UpdateRecord.  You could use client side scripting to make sure all necesary data elements were entered, and have the Save button submit the information to let's say "AddRecord.asp".  AddRecord.asp would be the page with the recordset control.  From AddRecord.asp you could use either Request.Form("textboxname") or Request.QueryString("textboxname")(this is dependant on which method the form submits the data with - get or post) to retrieve the data from the form.  I don't know exactly how methods work for DTC controls, but the code might look something like this.

rsDTC.Field1 = Request.Form("textboxname")

Like I said - I'm somewhat guessing here, but maybe it'll stir up some thoughts for you.  Thanks for your patience and feedback.

Sorry sandeeptyagi, no help here.  But I am curious, what's DTC?

sandeeptyagiAuthor Commented:
hi spruce22

u wanted to know about DTC's.

 well... DTC stands for Design Time Control. they come with vis. interdev  6.0 , and are used to reduce the hard-Coding. u can simply drag them over to ur asp page ,change the properties. and that's it. they will generate the equivalent script for u. so u see they are of great use. like for creating a recordset manually, u need to write so many stmts. for ex., creating an instance of connection, recordset, then those commands, locking type, cursor type , command time out and so and so. now if u go for using one of DTC recordset, it's fun. there are several other DTC controls as well.
now u don't take them to be ActiveX controls. these are not ActiveX controls . But only a graphical representation of the same hard-coding. so ultimately u are getting the same stmts( more professionaly written) and ofcourse easy to customise. and therefore u don't need them to be registered anywhere on server or look for any browser plugin.all u need is to know how to use them.

   i would suggest u to try them if u really are unaware of them and so far doing hard-coding. for  i'm sure they'll make ur life comfortable to some extent.

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions


Aren't there events for the DTC text box control?  Something like OnChange, or AfterUpdate?  I'm famaliar with events in Access, not ASP but I know there has to be one which would be suitable.  This way, when a user enters data into the text box, you add the new record.  When they are completed they'd press save.

Thanks for the explanation of DTC's:)
sandeeptyagiAuthor Commented:
dear spruce22
thanx for ur help. but let me tell u few things about DTc's.
when we use DTC's we get a chance to choose between either server or clint plateform, where we would kike this script to run. now if we choose server, and go for writing afterupdate of textfield then as many times user(surfer) updates(or i should say reenters) the control will go to server to execute the script .and that's highly unwanted.

so u see we can't go for that.

anyway thanx once more and feel free to speak ur mind

sandeeptyagiAuthor Commented:
hi spruce22
first of all sorry for the delay. the house was under heavy repairment
 so the system was put at such a place that i couldn't attach it to
 telephone line to access net. however i had received ur reply by then.

well.. what u said was absolutely right if i use 2 separate pages. and it
is not a problem. i wanted to do it with one page only. as of now i
have taken the very same root (2 diffrent pages) and it's working perfectly.
though in future if you come across the exact solution pls. let me know.


hi sandeep,

No problem on the delay, glad you were able to get your stuff working.  As far as finding the exact solution, it seems to me that you'd always have to use two pages to add the records, unless you wanted the page to update itself.  For example, your form could submit the data to itself, and then you could call the .AddRecord & .UpdateRecord.  But it seems like that would require much more server side scripting than is necesary.  Maybe somebody else would know of a different way to accomplish this, but I'm out of brains:)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.