Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid - use checkbox to save records to new table

Status
Not open for further replies.

revman

Programmer
Jun 20, 2001
2
ZA
Using a datagrid from visual interdev, i added an unbounded column to the
grid.
In the unbounded column is an unbounded checkbox.
This is my problem:
If the user select the textbox, I want to write the row in the data grid to
another table.
The procedure can run when the user select the checkbox, or afterwards when
a submit button is clicked.
I do not know how to achieve this.
I am using visual interdev, and the database is sql 2000.
Any help, or reference to technical articles will be appreciated.
Thanks
 
Hi revman,

I haven't got all the syntax worked out, but this should get you started...The For loop will may have to be replaced with something else to allow for you to cycle thru the rows in the grid from top to bottom.

I would create a button (btnInsert) and do all the inserts at once. For example, code would resemble:

btnInsert_onclick()
Dim b_checkbox_state
Dim i_rows
Dim i

' Get total rows
i_rows = rs.getcount() 'RS for grid

For i to i_rows
b_checkbox_state = ?get value of checkbox on each row
if b_checkbox_state = true then
' Get data values for row
strname = txtname.value(row #? not sure of syntax)
' Get the values for rest of columns

' Prepare to do a query from the Data Environment
Set DE = Server.CreateObject("DERuntime.DERuntime")
DE.Init(Application("DE"))

' Insert record using predefined DE commands
' Which is defined to used proc to perform insert
' takes input values as parameters
Call DE.cmdInsertRec(strname, other col data variables)
'Your Proc could return an output variable containing the
' error code (contained in @@error for sql server)
i_result=DE.Commands("InsertRec").Parameters("result")
if i_result <> 0 then
' perform some error rtn here
' What if record already exists...
end if

Next

End Sub

Good Luck,

Computergeek

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top