Solved

Using VB to connect to MSSQL Server

Posted on 2003-10-24
9
1,972 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Put text in a picture ASP.NET C# 2 50
Excel VBA, find a string in a column, update a cell 7 66
VB6 ListBox Question 4 32
Problem to With line 4 41
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now