Wrox Home  
Search P2P Archive for: Go

  Return to Index  

activex_data_objects thread: RE: Active X - databases


Message #1 by Thomas Bellavia <TBellavia@V...> on Tue, 28 Aug 2001 09:41:05 -0400
Make sure you do not write multiple (equal) values in the primary key 

field.

This field probably doesn't accept duplicate values.



-----Original Message-----

From: Ken McIntosh [mailto:ken.mcintosh@s...]

Sent: Friday, July 06, 2001 4: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 access97

database.  One of the fields is set as the primary key (required) in the

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



---

* Fast, Full-Featured Microsoft=AE Excel Web Reports & Charts!

A breakthrough in high performance Web application development,

SoftArtisans ExcelWriter 1.1 supports native Excel charting,

image insertion, and advanced functions & formatting. One click

generates presentation-quality Excel spreadsheets-and ExcelWriter

performs over 100 times faster than the Excel Object. Several

editions, including ExcelWriterFREE, are available.

http://www.softartisans.com/softartisans/excelwriter.html



tbellavia@v...


$subst('Email.Unsub')


  Return to Index