p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 22nd, 2008, 11:55 AM
Registered User
 
Join Date: Oct 2008
Location: , , .
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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 22nd, 2008, 12:07 PM
Friend of Wrox
Points: 6,570, Level: 34
Points: 6,570, Level: 34 Points: 6,570, Level: 34 Points: 6,570, Level: 34
Activity: 42%
Activity: 42% Activity: 42% Activity: 42%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,000
Thanks: 5
Thanked 37 Times in 36 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
================================================== =========
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old October 22nd, 2008, 12:11 PM
Registered User
 
Join Date: Oct 2008
Location: , , .
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old October 22nd, 2008, 12:18 PM
Friend of Wrox
Points: 6,570, Level: 34
Points: 6,570, Level: 34 Points: 6,570, Level: 34 Points: 6,570, Level: 34
Activity: 42%
Activity: 42% Activity: 42% Activity: 42%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,000
Thanks: 5
Thanked 37 Times in 36 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
================================================== =========
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old October 22nd, 2008, 12:32 PM
Registered User
 
Join Date: Oct 2008
Location: , , .
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old October 22nd, 2008, 01:04 PM
Friend of Wrox
Points: 6,570, Level: 34
Points: 6,570, Level: 34 Points: 6,570, Level: 34 Points: 6,570, Level: 34
Activity: 42%
Activity: 42% Activity: 42% Activity: 42%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,000
Thanks: 5
Thanked 37 Times in 36 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
================================================== =========
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 06: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 04: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 11:46 AM



All times are GMT -4. The time now is 08:04 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc