Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2008, 10:55 AM
Registered User
 
Join Date: Oct 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connect to SQL Database with Visual Basic 2008

Hi

I am converting a project over from Excel VBA to Visual Basic 2008, but I am completely stuck on how to connect to my SQL database, and subsequently manipulate the data, the excel VBA code is as follows:
Code:
szConnection = "ODBC;UID=ADMIN;PWD=;DSN=Colleague32"
Set wrkODBC = CreateWorkspace("ODBCSpace", "admin", "", dbUseODBC)
Set conPubs = wrkODBC.OpenConnection("", , , szConnection)
sql = "Select * from users"
Set rstTemp1 = conPubs.OpenRecordset(szSQL1, dbOpenSnapshot, dbRunSync)
    With rstTemp1
        Do While Not .EOF
            /*My code here*/
            .movenext
        loop


I can't figure out how to get the connection to my SQL database or what the commands are.
Please can any one help on this, I would be very grateful.

Thank You
John



 
Old October 22nd, 2008, 11:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there.. are you trying to connect to SQL server?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old October 22nd, 2008, 11:11 AM
Registered User
 
Join Date: Oct 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Gonzalo

Yes the database is on a server. It will only be used over a LAN and will not go on to the internet.

Cheers

John

 
Old October 22nd, 2008, 11:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

NO, I mean if the database is SQL SERVER (2000,2005)??? or mysql? or oracle?

You have propietary objects for that type of databases and a lot of info in google on how to connect to them and handle them. Even if the database is oracle, you can connect to it using proprietary objects.

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old October 22nd, 2008, 11:32 AM
Registered User
 
Join Date: Oct 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry mis-understood.
It is SQL server 2000.

I have looked at google and can't make out exactly what is needed by Visual Basic.

Cheers

John

 
Old October 22nd, 2008, 12:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Well, this query "how to connect sql server 2000 vb.net" throw a lot of results in google.

Anyway, .net use a complete different way to connect to a database, also to handle "recordsets". Depends on what you need, is what you open an use to process. There are objects that you can just throw on the form to make the connection open automatic. There is no more recordset, now you have datatables (something like a table), datasets and others. Maybe you can start digging from there.

The easy answer would be, you have to create a connection object and pass the connection string to it, open it, then build a datatable for what you need.

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Visual Basic 6 connect to SQL server? mytreasure23 SQL Server 2000 2 August 31st, 2006 05:02 AM
Beginning Visual Basic 6 database zach007 Wrox Book Feedback 1 January 24th, 2006 11:42 PM
Beginning Visual basic 6.0 DataBase visualizebasic Wrox Book Feedback 0 June 14th, 2005 03:41 AM
SQL and Visual Basic mytreasure23 SQL Server 2000 1 November 9th, 2004 03:26 AM
beginning visual basic 6 database programming gskarns1 VB Databases Basics 1 September 29th, 2004 10:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.