SQL Server 2000General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2000 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.
I'll give you a brief run down.......
1) You need to have a reference to ADO, done by selecting from the menu > Project > References and check Microsoft ActiveX Data Ojects 2.X Library (assuming you have mdac installed - get this from microsoft if you dont)
2) Create connection and command objects....(this should come up with intellisense if you have it installed properly)
Dim Connection As New ADODB.Connection
Dim Command As New ADODB.Command
3) Login....
Connection.ConnectionString = "driver={SQL Server};server=YOURSERVER;uid=YOURUSER;pwd=YOUPASS WORD;database=YOURDATABASE"
Connection.Open
Command.ActiveConnection = Connection
4) Call your procedure
Dim ResultSet As New ADODB.Recordset
Command.CommandText = "YOURPROCEDURE"
Set ResultSet = Command.Execute
5) Work with you results
Dim value as String
If ResultSet.BOF = True And ResultSet.EOF = True Then
value = ResultSet.Fields(0)
End If
This is just 1 way, but it will give you an idea, but have a look for ADO on the net. You only asked for how to connect but I gave you the code to call a stored procedure also and this post should probably be in a VB thread.