al4629740
asked on
record not updating to the table
I am having issues with this code in VB6. When i click the command button, the new record will show up in the datagrid but then it wont update to the table. Do you see anything missing or wrong?
Private Sub Command7_Click()
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
If conn.State = adStateClosed Then
conn.Open "Provider=sqloledb;Data Source=" & ConnectionIP & ",xxxxx;Network Library=DBMSSOCN;Initial Catalog= " & CAPDB & "; User ID=xxxx;Password=xxxxx"
End If
esql = "select LinkageName, Linkage, AgreementDate from tblOrgMonthlyLinkages where Fiscal = " & Fiscal & " order by AgreementDate"
If rec.State = adStateOpen Then
rec.Close
End If
rec.CursorType = adOpenStatic
rec.CursorLocation = adUseClient
rec.LockType = adLockOptimistic
rec.Open esql, conn, , , adCmdText
rec.AddNew
rec!LinkageName = Text3
rec!Linkage = Text5
rec!AgreementDate = DTPicker4
rec.Update
Set DataGrid1.DataSource = rec
If rec.RecordCount > 0 Then
rec.MoveFirst
End If
DataGrid1.Columns(0).Width = 2500
DataGrid1.Columns(1).Width = 4500
DataGrid1.Columns(2).Width = 1500
End Sub
ASKER
I made the change you suggested, but it still does not save the record
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Issue out of the scope of my asked question
Open in new window