I am just learning to use databases with VB. I am converting a DOS program that uses an older ISAM database to VB
I am working on adding a new employ to the database and I was wondering the best way to go about it. In an example I have seen, the programmer had 3 textboxes to collect the data, these values were held in variables (ex: Name$ = text1.text) then the INSERT INTO statement was used to insert the data into the database.
In the original program I am converting, the data was put into the database field buffer (MF.LName) and then inserted at the end (LSet PayRec = MF: INSERT 5, PayRec), basically like you do with a file and the PUT statement. The orginal progammer made the comment that using variables to hold the data seemed like a waste. I have 29 textboxes so I would be using 29 variables. Is there another way to save the data to be inserted?
Just some added info, the textboxes are an array and are not bound, and on some I use various verification routines. I am using an Access database
Here is a sample of the insert string (Just a small portion of what it would be)
stSQL$ = "INSERT INTO Master"
stSQL$ = stSQL$ & "("
stSQL$ = stSQL$ & "PAYEMP,DIVA,DEPTA,ACCTA,RATEA,"
stSQL$ = stSQL$ & "DIVB,DEPTB,ACCTB,RATEB,"
stSQL$ = stSQL$ & "DIVC,DEPTC,ACCTC,RATEC"
stSQL$ = stSQL$ & ""
stSQL$ = stSQL$ & " VALUES"
stSQL$ = stSQL$ & "("
stSQL$ = stSQL$ & IsNVLString(FEmp$) & ","
stSQL$ = stSQL$ & PRRADI & ","
stSQL$ = stSQL$ & PRRADE & ","
stSQL$ = stSQL$ & PRRAA & ","
stSQL$ = stSQL$ & PRRTA & ","
stSQL$ = stSQL$ & PRRBDI & ","
stSQL$ = stSQL$ & PRRBDE & ","
stSQL$ = stSQL$ & PRRBA & ","
stSQL$ = stSQL$ & PRRTB & ","
stSQL$ = stSQL$ & PRRCDI & ","
stSQL$ = stSQL$ & PRRCDE & ","
stSQL$ = stSQL$ & PRRCA & ","
stSQL$ = stSQL$ & PRRTC & ""
Access.Execute stSQL$
Basically I am wanting to know if saving all the data into separate variables (29) then using the INSERT INTO method is the best way to add a new record.
Thanks for any advice
Catrina [sig][/sig]
I am working on adding a new employ to the database and I was wondering the best way to go about it. In an example I have seen, the programmer had 3 textboxes to collect the data, these values were held in variables (ex: Name$ = text1.text) then the INSERT INTO statement was used to insert the data into the database.
In the original program I am converting, the data was put into the database field buffer (MF.LName) and then inserted at the end (LSet PayRec = MF: INSERT 5, PayRec), basically like you do with a file and the PUT statement. The orginal progammer made the comment that using variables to hold the data seemed like a waste. I have 29 textboxes so I would be using 29 variables. Is there another way to save the data to be inserted?
Just some added info, the textboxes are an array and are not bound, and on some I use various verification routines. I am using an Access database
Here is a sample of the insert string (Just a small portion of what it would be)
stSQL$ = "INSERT INTO Master"
stSQL$ = stSQL$ & "("
stSQL$ = stSQL$ & "PAYEMP,DIVA,DEPTA,ACCTA,RATEA,"
stSQL$ = stSQL$ & "DIVB,DEPTB,ACCTB,RATEB,"
stSQL$ = stSQL$ & "DIVC,DEPTC,ACCTC,RATEC"
stSQL$ = stSQL$ & ""
stSQL$ = stSQL$ & " VALUES"
stSQL$ = stSQL$ & "("
stSQL$ = stSQL$ & IsNVLString(FEmp$) & ","
stSQL$ = stSQL$ & PRRADI & ","
stSQL$ = stSQL$ & PRRADE & ","
stSQL$ = stSQL$ & PRRAA & ","
stSQL$ = stSQL$ & PRRTA & ","
stSQL$ = stSQL$ & PRRBDI & ","
stSQL$ = stSQL$ & PRRBDE & ","
stSQL$ = stSQL$ & PRRBA & ","
stSQL$ = stSQL$ & PRRTB & ","
stSQL$ = stSQL$ & PRRCDI & ","
stSQL$ = stSQL$ & PRRCDE & ","
stSQL$ = stSQL$ & PRRCA & ","
stSQL$ = stSQL$ & PRRTC & ""
Access.Execute stSQL$
Basically I am wanting to know if saving all the data into separate variables (29) then using the INSERT INTO method is the best way to add a new record.
Thanks for any advice
Catrina [sig][/sig]