Solved

Using VB to connect to MSSQL Server

Posted on 2003-10-24
9
1,987 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I need help formating a date variable in my VB.Net application 2 60
JSON Response and request in VB6 application 11 580
Add and format columns in vb6 7 63
Excel Automation VBA 19 89
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

860 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