?
Solved

SQL with VB

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

Author Comment

by:mithunthakur
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
0
 
LVL 53

Accepted Solution

by:
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"
cn.open

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
  rs.movenext
wend

end sub

0
 
LVL 18

Assisted Solution

by:Sethi
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:
http://www.vbcode.com/asp/code.asp?lstCategory=Database
http://www.codeguru.com/vb/Database/index.shtml
0
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

by:sherrymks
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
0
 

Expert Comment

by:CleanupPing
ID: 8940445
mithunthakur:
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?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8983635
Moderator, my recommended disposition is:

    Split points between: Dhaest and Sethi

DanRollins -- EE database cleanup volunteer
0

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