I have a MSHFlexGrid that I fill with data from a database, kind of like an invoice. I need to add data to the FlexGrid and add the new lines to the database, while updating the existing records. How would I do this.
I write the FlexGrid data to the database as follows:
Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = "Driver=SQL Server;uid=;pwd=;Server=RobOffice;DAtabase=Test"
cn.ConnectionString = 30
cn.Open
sql = "Select * from DAinfo Where claimNo = '" & txtDANo.Text & "'"
rs.Open sql, cn, adOpenKeyset, adLockOptimistic
With flexDA
For xRow = 2 To .Rows - 1
Item = "'" & txtDANo.Text & "'"
For xCol = 0 To .Cols - 1
Item = Item & IIf(Len(Item) > 0, ", ", "" & "'" & .TextMatrix(xRow, xCol) & "'"
Next xCol
sql = "Insert into DAInfo (ClaimNo, Operation, PartType, Part#, PartName, Quantity, Hours, Materials, PartPrice, ExtPrice, Vendor#, Group#, Req#, Ref#) Values (" & Item & ""
MsgBox (sql)
cn.Execute sql
Next xRow
End With
I'm using the same code to write the data back to the database but it adds all of the information again, including what is already there. (selected to fill the grid)
How would I write the new information to the database while just updating the existing rows if the information changes. (the information on the existing rows is subject to change.)
TIA
Rob
Rob
Just my $.02.