SQL with VB

Posted on 2003-02-27
Medium Priority
Last Modified: 2010-05-01
how we can use SQL with VB? what are the requirements for all.
Question by:mithunthakur
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

Author Comment

ID: 8032239
plz help me i can use SQL but not upto that much level. acctualy i want to access ODBC databases through VB. how to make connections and all plz help me
LVL 53

Accepted Solution

Dhaest earned 200 total points
ID: 8032264
' Easy example of using oracle as database (for sql-server, same thing to user, except the connectionstring)

dim cn as ADODB.Connection
dim rs as ADODB.Recordset

private sub form_load()

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset

cn.ConnectionString = "Driver={Microsoft ODBC for Oracle};SERVER=servername;UID=username;PWD=paswoord"

rs.open "select * from your table",cn,adOpenForwardOnly, adLockOptimistic

For example, put every field in a textbox

while not rs.eof
  text1.text = text1.text & rs.fields(0) & "-" & rs.Fields(1) & vbcrlf

end sub

LVL 18

Assisted Solution

Sethi earned 200 total points
ID: 8032276
You will ahve to learn DAO or ADO for that. ADO is the most recommended one. The SQL statment can then be executed by using the Connection or the recordset object of ADO. Look at these links for tutorials and samples of ADO:
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!


Expert Comment

ID: 8032558
the solution suggested by dhaests  will work fine
but you may have still problems with connectio string
the easiest way to get the correct connection string is
you place an oledb data control on any form. then go to the property page for connection string
use buil option and follow the steps
so you will get the correct connection string that fits your database

Expert Comment

ID: 8940445
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
LVL 49

Expert Comment

ID: 8983635
Moderator, my recommended disposition is:

    Split points between: Dhaest and Sethi

DanRollins -- EE database cleanup volunteer

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses

770 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