Microsoft KB Archive/173648

= HOWTO: Updating an Oracle Table Using DBGrid and RDO =

Article ID: 173648

Article Last Modified on 4/18/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Enterprise Edition

-



This article was previously published under Q173648



SUMMARY
One way to set up a connection to Oracle and modify the data is by using the Microsoft Data Bound Grid. The steps listed below allow the user to accomplish this task. This example uses a DSN-less connection.



MORE INFORMATION
 Create a new Standard EXE project in Visual Basic. On the Project menu, click Components and select "Microsoft Data Bound Grid Control." Also, click "Microsoft RemoteData Control 2.0." (NOTE: This adds two new icons to the toolbar for the RemoteData Control and DBGrid.) On the Project menu, click References, and click "Microsoft Remote Data Object 2.0." Place a DBGrid, RemoteData Control, and a command button on the form. Select the DBGrid, and set the DataSource property to "MSRDC1", which is the default name of the RemoteData Control. Also ensure the AllowUpdate property is True (default), and if adding new records set AllowAddNew property to True (default is False).  Add the following code to the click event of the command button: Dim myenv as rdoEnvironment Dim mycn as rdoConnection Dim mydsnless as String Dim mysql as String

mydsnless = "driver={Microsoft ODBC Driver for Oracle};" _ "Uid=pss; Pwd=pss;ConnectString=tns:ncoracle73;" _

Set myenv = rdoEnvironments(0) Set mycn = myenv.OpenConnection("",false,rdDriverPrompt,mydsnless)

mysql = "Select * from demo.customer"

Set Form1.MSRDC1.Resultset = mycn.OpenResultset(mysql,rdOpenKeyset, _         rdConcurRowVer)

Debug.Print mycn.Connect ' Display the connection string

 Run the form, change a value in the Grid, and move off the row to update.</li></ol>

In the steps above, the driver being used is the Microsoft Oracle driver. You need to modify Uid, Pwd, and ConnectString to fit your ODBC setup.

Additional query words: remote data

Keywords: kbhowto KB173648

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.