Solved

RDO Connection problem

Posted on 2001-07-11
6
506 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
6 Comments
 
LVL 50

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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 50

Expert Comment

by:Ryan Chong
ID: 6276862
Hi kirtirani,

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 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