Solved

RDO Connection problem

Posted on 2001-07-11
6
508 Views
Last Modified: 2008-02-01
Hi All,

I am very new to VB and now I have started coding in VB. I have to write an application using SQL server as a backend and RDO connection. I am having difficulty in writing the code for RDO. Can anyone help me and can give me the code for establishing the connection and executing the query with RDO thru VB. I need it urgently.

Kirti
0
Comment
Question by:kirtirani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 51

Accepted Solution

by:
Ryan Chong earned 200 total points
ID: 6275532
Hi kirtirani,

This class demo maybe can help you:

Demonstrates the creation of Master/Detail form using an RDO connection, also helps understand the object oriented programming concepts in VB.

http://www.vbcode.com/code/MDForm.zip

Anyway, you can use the RDO Control in component, follow the wizard provided, it is much easier stuff.

Basically, RDO is perform as well as the ADO.

'Hope will help.
0
 

Author Comment

by:kirtirani
ID: 6275665
Hi ryancys,
thanx for ur program but the thing is I don't want to use the RDO control. and i can use ADO also its upto me. so please suggest which one is better and provide some more useful stuff.
kirti
0
 

Expert Comment

by:Matdone
ID: 6275776
Here is the code I use. It is in ADO. This will retrive the information from the table. You can use a DSNless connection or one that uses a DSN.

Sub GetSql()
Dim RSSQL As ADODB.Recordset

'This is the dsnless connection
ConnectStrSQL = "Provider=SQLOLEDB.1; Network Library=dbmssocn;Password=Password;User ID=UserName;Initial Catalog=DatabaseName;Data Source=ServerName;"

'This is the DSN connection string. this is the easiest method
ConnectStrSQL = "DSN=Pubs;UID=sa;PWD=pwd;"

'Open Sql Database for updating
Set RSSQL = New ADODB.Recordset
RSSQL.ActiveConnection = ConnectStrSQL
RSSQL.CursorType = adOpenKeyset
RSSQL.LockType = adLockOptimistic
RSSQL.Open "Select * from table"

Hope this helps. Read up on ADO at msdn.microsoft.com/vbasic/technical/articles/ado20/default.asp

Matt
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 3

Expert Comment

by:jrspano
ID: 6276824
if you have the choice definately use ado instead of rdo.  MS as quit releasing new rdo stuff and don't really support it anymore.
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6276852
also the above way shown is slow as you have to reconnect to the db every time you want the recordset you should use a connection object if you have to get a bunch of recordsets

ex

dim cn as adodb.connection
dim rs1 as adodb.recordset
dim rs2 as adodb.recordset

set cn = new adodb.connection
set rs1 = new adodb.connection
set rs2 = new adodb.connection

cn.connectionstring = "DSN=mydsn" 'or use a dsn less one
cn.open

dim sql as string
dim sql2 as string
sql = "sql query"
sql2 = "sql2 query"

rs1.open sql, cn, adopenstatic, adlockreadonly
rs2.open sql2, cn, adopenstatic, adlockreadonly

do stuff with rs's

rs1.close
rs2.close
cn.close

set rs1 = nohting
set rs2 = nothing
set cn = nothing
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6276862
Hi kirtirani,

This might be useful: http://www.able-consulting.com/tech.htm
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question