Solved

Using VB to connect to MSSQL Server

Posted on 2003-10-24
9
1,998 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

691 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