?
Solved

ADO

Posted on 1998-10-20
4
Medium Priority
?
487 Views
Last Modified: 2013-12-25
how do i use ADO in VB to access SQL Server?

i'm using ADO version 2.0, SQL SERVER 6.5, VB 5.0.
0
Comment
Question by:ireeny
[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
  • 3
4 Comments
 

Accepted Solution

by:
narula earned 20 total points
ID: 1497100
First, make sure that you've installed the latest Data Access Components (http://www.microsoft.com/data).  Also, be aware that you will not be able to directly use SQL Server as an OLEDB data source.  You will have to use the OLEDB to ODBC provider or more likely you will use ODBC directly.  In any event, make sure you have an ODBC System DSN created for your SQL database.

In VB, make sure that there's a project reference to the ADO 2.0 library.  Be warned that there's no direct binding of controls here.  You'll have to do all of this manually by coding your bindings (or upgrade to VB6).  Now, assuming your using a standard form:
' In general declarations
Dim conn as ADODB.Connection

' In the Form_Load event procedure
  conn.open ConnectionString,UserID,Password
' and so on

It's as simple to use as under ASP.  If you're looking for a more RAD approach, goto the Microsoft Online Member Downloads page and download the from ISG Data Control which works with ADO Recordsets. :-)

0
 

Author Comment

by:ireeny
ID: 1497101
great ! that worked.

however, i can't seem to retrieve data into a DBGRID.
how do i overcome this ?

(if you help me with this, i'll increase points to 20 ! thanks )
0
 

Expert Comment

by:narula
ID: 1497102
Let me correct this by saying that if you download the latest Data Access, you should have the ability to use the SQL OLEDB provider.  I'd forgotten that it was included recently.
0
 

Expert Comment

by:narula
ID: 1497103
Well...I'm not going to sit here and write the code for you, but I will give you some idea - since the VB5 grid doesn't bind to ADO (unless you use the free ISGData Control for ADO *hint*).

First, grab your recordset and with the fields collection, add a corresponding column to the DBGrid's Columns collection, setting the Visible and Caption properties.  Then set the AllowAddNew property to True and for each record in your recordset by using the Bookmark property and the columns collection of the DBGrid, and incrementally add values into each cell of that DBGrid row.  When you reach the end of each row, move to the next row and repeat the last step until you've reached the end of the recordset.

As I said before, this is the unbound way - and it's time consuming.  Now, after you've updated the grid, you'll have to save changes by evaluating each row and saving it's values.  Do yourself a favor and download the ISGData Control for ADO at: http://premium.microsoft.com/msdn/downloads/isgdata/default.htm

0

Featured Post

Independent Software Vendors: 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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 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