Solved

Using VB to connect to MSSQL Server

Posted on 2003-10-24
9
1,959 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

708 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

15 Experts available now in Live!

Get 1:1 Help Now