If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Want the code to connect Sql server7.0 with vb6.0

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-03-03, 05:40
robinvt robinvt is offline
Registered User
 
Join Date: Nov 2003
Location: dubai
Posts: 1
Want the code to connect Sql server7.0 with vb6.0

Dear friends,
I know to connect access with VB6.0.
But now i have a project in VB6.0 and Sql Server.I am perplexed.Can anyone forward me the code in VB6.0 to connect it to a database in SQL Server7.0
Reply With Quote
  #2 (permalink)  
Old 11-03-03, 20:20
KarSoV KarSoV is offline
Registered User
 
Join Date: Oct 2003
Location: Portugal
Posts: 4
Re: Want the code to connect Sql server7.0 with vb6.0

You can do something like this!!!

'Use as reference: Microsoft ActiveX Data Objects 2.X Library
'Code:

Public intConnection As ADODB.Connection

Public Sub Open_Conn(Server_Name As String, Data_Base As String, Login As String, Password As String)
Set intConnection = New ADODB.Connection
intConnection.ConnectionString = "driver={SQL Server}" & _
";server=" & Server_Name & _
";uid=" & Login & _
";pwd=" & Password & _
";database=" & Data_Base
intConnection.Open
Activo = True
End Sub

Public Sub Close_Conn()
intConnection.Close
Set intConnection = Nothing
End Sub

Private Function Get_Value(Field As String, Table As String) As String
Dim rstValue As ADODB.Recordset
Dim strQry As String
strQry = "SELECT " & Field & " FROM " & Table
Set rstValue = New ADODB.Recordset
rstValue.Open strQry, intConnection, adOpenStatic, adLockReadOnly, adCmdText
If rstValue.EOF Then
Get_Value = ""
Else
Get_Value = strQry(0)
End If
rstValue.Close
Set rstValue = Nothing
End Function
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On