|
 |
activex_data_objects thread: Active X - databases
Message #1 by "Ken McIntosh" <ken.mcintosh@s...> on Fri, 6 Jul 2001 08:57:40
|
|
Hi,
Can you help.. I have created an active x control that updates a access 97
database. One of the fields is set as the primary key (required) in tha
database, when I try to update (rs.Update) the info I get the following
error message Run-time error '2147217873(8004oe2f) [Microsoft][ODBC
Microsoft Access Driver]Error in Row. However when I remove the primary
key allocation to the field in the database the active x control works
fine and updates the record. Are there some restrictions I'm missing with
ADO regarding databases and primary keys..I need this key to be set as the
primary key (indexed) as I have another vb app that connects to it using
DAO and searches for records using the SEEK method.
Is there something I'm missing...Any ideas on how get round this
problem..The code I use is below
Thanks & Regards
Ken
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub UserControl_Initialize()
cn.Open "DSN=IP"
'OPEN A RECORDSET
Set rs = New ADODB.Recordset
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Source = "version2"
rs.ActiveConnection = cn
rs.Open
'Add in here the code to increment the IP number each time the form loaded.
End Sub
Private Sub UserControl_Resize()
With UserControl
'Enfore minimum dimensions
If .Height < 9000 Then .Height = 9000
If .Width < 7920 Then .Width = 7920
'Resize the objects on the control
txtSwVer.Width = .ScaleWidth - 500
txtProdName.Width = .ScaleWidth - 500
End With
End Sub
Public Property Get IPText() As String
Dim s As String
s = txtSwVer
s = s & txtProdName & vbCrLf
s = s & txtProdID & vbCrLf
s = s & txtSupCont & vbCrLf
IPText = s
End Property
Private Sub cmdCommit_Click()
rs.AddNew
rs.Fields("ProductName") = txtProdName
rs.Fields("ProductID") = txtProdID
rs.Fields("SWVersion") = txtSwVer
rs.Fields("SupportContact") = txtSupCont
rs.Fields("SupportAddress") = txtSuppAdd
rs.Fields("SupportTele") = txtTel
rs.Fields("SupportFax") = txtFax
rs.Fields("SupportContact") = txtSupCont
rs.Fields("SupportGroup") = txtSuppGroup
rs.Fields("SupportExpiry") = txtSuppExp
rs.Fields("ForUseBy") = txtUseBy
rs.Fields("CountryOrg") = txtCountryOrg
rs.Fields("Receiver") = txtRec
rs.Fields("ReceiverAddress") = txtAddRec
rs.Fields("ReceiverTel") = txtRecTel
rs.Fields("ReceiverFax") = txtRecFax
rs.Fields("MediaDispatcher") = txtDispatcher
rs.Fields("MediaTele") = txtMediaTel
rs.Fields("MediaFax") = txtMediaFax
rs.Fields("MediaDescription") = txtMediaDesp
rs.Fields("VirusTool") = txtVirusTool
rs.Fields("VirusCheckedBy") = txtCheckBy
rs.Fields("RiskAssessment") = txtRisk
rs.Fields("Reason") = txtReason
rs.Fields("Tar") = txtTar
rs.Fields("TarDescription") = txtTarDesp
rs.Fields("Library") = txtLib
rs.Fields("ForecastDate") = txtForecast
rs.Update
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub
Message #2 by Kyle Burns <kburns@c...> on Fri, 6 Jul 2001 10:29:37 -0500
|
|
Which field is the primary key? Are you trying to assign it a unique
value?
-----Original Message-----
From: Ken McIntosh [mailto:ken.mcintosh@s...]
Sent: Friday, July 06, 2001 3:58 AM
To: ActiveX_Data_Objects
Subject: [activex_data_objects] Active X - databases
Hi,
Can you help.. I have created an active x control that updates a access
97
database. One of the fields is set as the primary key (required) in
tha
database, when I try to update (rs.Update) the info I get the following
error message Run-time error '2147217873(8004oe2f) [Microsoft][ODBC
Microsoft Access Driver]Error in Row. However when I remove the
primary
key allocation to the field in the database the active x control works
fine and updates the record. Are there some restrictions I'm missing
with
ADO regarding databases and primary keys..I need this key to be set as
the
primary key (indexed) as I have another vb app that connects to it
using
DAO and searches for records using the SEEK method.
Is there something I'm missing...Any ideas on how get round this
problem..The code I use is below
Thanks & Regards
Ken
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub UserControl_Initialize()
cn.Open "DSN=3DIP"
'OPEN A RECORDSET
Set rs =3D New ADODB.Recordset
rs.CursorType =3D adOpenKeyset
rs.LockType =3D adLockOptimistic
rs.Source =3D "version2"
rs.ActiveConnection =3D cn
rs.Open
'Add in here the code to increment the IP number each time the form
loaded.
End Sub
Private Sub UserControl_Resize()
With UserControl
'Enfore minimum dimensions
If .Height < 9000 Then .Height =3D 9000
If .Width < 7920 Then .Width =3D 7920
'Resize the objects on the control
txtSwVer.Width =3D .ScaleWidth - 500
txtProdName.Width =3D .ScaleWidth - 500
End With
End Sub
Public Property Get IPText() As String
Dim s As String
s =3D txtSwVer
s =3D s & txtProdName & vbCrLf
s =3D s & txtProdID & vbCrLf
s =3D s & txtSupCont & vbCrLf
IPText =3D s
End Property
Private Sub cmdCommit_Click()
rs.AddNew
rs.Fields("ProductName") =3D txtProdName
rs.Fields("ProductID") =3D txtProdID
rs.Fields("SWVersion") =3D txtSwVer
rs.Fields("SupportContact") =3D txtSupCont
rs.Fields("SupportAddress") =3D txtSuppAdd
rs.Fields("SupportTele") =3D txtTel
rs.Fields("SupportFax") =3D txtFax
rs.Fields("SupportContact") =3D txtSupCont
rs.Fields("SupportGroup") =3D txtSuppGroup
rs.Fields("SupportExpiry") =3D txtSuppExp
rs.Fields("ForUseBy") =3D txtUseBy
rs.Fields("CountryOrg") =3D txtCountryOrg
rs.Fields("Receiver") =3D txtRec
rs.Fields("ReceiverAddress") =3D txtAddRec
rs.Fields("ReceiverTel") =3D txtRecTel
rs.Fields("ReceiverFax") =3D txtRecFax
rs.Fields("MediaDispatcher") =3D txtDispatcher
rs.Fields("MediaTele") =3D txtMediaTel
rs.Fields("MediaFax") =3D txtMediaFax
rs.Fields("MediaDescription") =3D txtMediaDesp
rs.Fields("VirusTool") =3D txtVirusTool
rs.Fields("VirusCheckedBy") =3D txtCheckBy
rs.Fields("RiskAssessment") =3D txtRisk
rs.Fields("Reason") =3D txtReason
rs.Fields("Tar") =3D txtTar
rs.Fields("TarDescription") =3D txtTarDesp
rs.Fields("Library") =3D txtLib
rs.Fields("ForecastDate") =3D txtForecast
rs.Update
rs.Close
cn.Close
Set rs =3D Nothing
Set cn =3D Nothing
End Sub
|
|
 |