|
|
 |
| 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.
|
 |

October 22nd, 2008, 11:55 AM
|
|
Registered User
|
|
Join Date: Oct 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

October 22nd, 2008, 12:07 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,000
Thanks: 5
Thanked 37 Times in 36 Posts
|
|
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
================================================== =========
|

October 22nd, 2008, 12:11 PM
|
|
Registered User
|
|
Join Date: Oct 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

October 22nd, 2008, 12:18 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,000
Thanks: 5
Thanked 37 Times in 36 Posts
|
|
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
================================================== =========
|

October 22nd, 2008, 12:32 PM
|
|
Registered User
|
|
Join Date: Oct 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

October 22nd, 2008, 01:04 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,000
Thanks: 5
Thanked 37 Times in 36 Posts
|
|
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
================================================== =========
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |