Results 1 to 9 of 9

Thread: Export data from Excel to SQL

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    Sub AddData()
        Dim oConn As Object
        Dim sSQL As String
        Set oConn = CreateObject("ADODB.Connection")
        oConn.Open "Provider=sqloledb;" & _
        "Data Source=myServerName;" & _
        "Initial Catalog=myDatabaseName;" & _
        "User Id=myUsername;" & _
        "Password=myPassword"
        sSQL = "INSERT INTO Contacts (FirstName, LastName,Phone, Notes) " & _
        "        VALUES ('Bob','Phillips','01202 345678','me')"
        oConn.Execute sSQL
        oConn.Close
        Set oConn = Nothing
    End Sub
    Last edited by Aussiebear; 03-03-2025 at 02:50 AM.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •