Solved

Using VB to connect to MSSQL Server

Posted on 2003-10-24
9
1,981 Views
Last Modified: 2013-12-25
Would somebody give me sourcecode or tutorial on using VB to connect to MSSQL Server ?
0
Comment
Question by:mikekwok
  • 2
  • 2
  • 2
  • +1
9 Comments
 
LVL 8

Expert Comment

by:MYLim
ID: 9618631
0
 

Author Comment

by:mikekwok
ID: 9618639
I would like to use ODBC and VB, would u send me reference ?
0
 

Accepted Solution

by:
mikekwok earned 0 total points
ID: 9618672
I have got a sample code :
http://www.deitel.com/books/vb6HTP1/vb6HTP1_examples.zip

extract the zip and go into this directory :chap18\Fig18_05 , there is sourcode here!!
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 3

Expert Comment

by:gafoorgk
ID: 9618745
use this

    Dim conn As New ADODB.Connection
   
    With conn
        .ConnectionString = "DRIVER={SQL Server};SERVER=SERVER102;Database=Northwind;UID=sa"
        .Open
    End With
0
 
LVL 8

Expert Comment

by:MYLim
ID: 9618746
thank's :)
0
 
LVL 3

Expert Comment

by:gafoorgk
ID: 9619283
i thought he was asking for ODBC connection string. the example he mentioned is using Jet OLEDB for Access.

his question was to use ODBC connection string for SQLSever database.
0
 
LVL 1

Expert Comment

by:VB-Expert
ID: 9619996

'MS ACCESS Connection Program
'Form

Private Sub cmdConn_Click()
    ''Access_Connect
    SetupConn
End Sub

Private Sub CmdEnd_Click()
    End
End Sub

Private Sub Form_Load()

End Sub

'Module

Global con As New ADODB.Connection
Global rst As New ADODB.Recordset
 
Sub SetupConn()
    con.Open "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "\Locations.mdb"
    rst.Open "Select * from CompInfo", con, adOpenDynamic, adLockOptimistic
End Sub


0
 
LVL 1

Expert Comment

by:VB-Expert
ID: 9620013
'MSSQL SERVER Connection Routine  (RDO)

    Set Eng = New rdoEngine
    Set Cn = New rdoConnection
    'this sets up the event handlers

    With Cn
        .Connect = "Uid=<user>;pwd=<password>;database=<DBname;dsn=<DataSourceName>;" _
        & "trusted_connection=yes"
        .LoginTimeout = 5
        .EstablishConnection rdDriverNoPrompt, True, rdAsyncEnable
    End With
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question