calling a function to save to a table
-
i have performed validation and populated a datagrid via a command button and using a "pseudo" (temporary) table called OrderDetails2. Now I wish to save the details to the proper table (ie OrderDetails), as every row in the datagrid as to be looped through to achieve this, I am using this code: Dim iRowCount As Integer 'Dim row As Integer iRowCount = Adodc3.Recordset.RecordCount For DataGrid2.row = 0 To iRowCount Call Save Next row the code in the save function is: Dim iOrderNumber As Integer iOrderNumber = RS.Columns("OrderNo") Dim strProductCode As String strProductCode = RS.Columns("ProductCode") Dim strProductDesc As String strProductDesc = RS.Columns("ProductDesc") Dim iProductQty As Integer iProductQty = RS.Columns("Quantity") Dim iOrderPrice As Integer iOrderPrice = RS.Columns("Price") Dim nSQL As String 'inserting the order into order detail nSQL = "Insert Into OrderDetail (OrderNo, ProductCode,ProductDesc, Quantity, Price) " & _ " Values (" & iOrderNo & ", '" & strCode & "', '" & strDesc & "', " & iQuantity & ", " & iFullPrice & ")" Set RS = Conn.Execute(nSQL) however, when run, a compile error is thrown "variable required - can't assign to this expression" (referring to the datagrid.row) what can i do to fix this or is there any different way to can achieve the same functionality? Thanking you!
-
i have performed validation and populated a datagrid via a command button and using a "pseudo" (temporary) table called OrderDetails2. Now I wish to save the details to the proper table (ie OrderDetails), as every row in the datagrid as to be looped through to achieve this, I am using this code: Dim iRowCount As Integer 'Dim row As Integer iRowCount = Adodc3.Recordset.RecordCount For DataGrid2.row = 0 To iRowCount Call Save Next row the code in the save function is: Dim iOrderNumber As Integer iOrderNumber = RS.Columns("OrderNo") Dim strProductCode As String strProductCode = RS.Columns("ProductCode") Dim strProductDesc As String strProductDesc = RS.Columns("ProductDesc") Dim iProductQty As Integer iProductQty = RS.Columns("Quantity") Dim iOrderPrice As Integer iOrderPrice = RS.Columns("Price") Dim nSQL As String 'inserting the order into order detail nSQL = "Insert Into OrderDetail (OrderNo, ProductCode,ProductDesc, Quantity, Price) " & _ " Values (" & iOrderNo & ", '" & strCode & "', '" & strDesc & "', " & iQuantity & ", " & iFullPrice & ")" Set RS = Conn.Execute(nSQL) however, when run, a compile error is thrown "variable required - can't assign to this expression" (referring to the datagrid.row) what can i do to fix this or is there any different way to can achieve the same functionality? Thanking you!
Set RS = Conn.Execute(nSQL)
I think the above statement is the problem .. you execute a statement that inserts data in a table and does not return a recordset .. try using :Conn.Execute(nSQL)