connection to internet mysql-database

  • Thread starter Thread starter masterphilch
  • Start date Start date
M

masterphilch

Hi

I established a connection to a database via "importing external data"
included in the excel-menu. Unfortunately, there's no such tool to write
data into a database. I just changed the sql-string an exept from an
error, the data is written into it. But I'v read that I can connect to a
database through proper vba-code. Can someone tell me if I have to link
other objects, which objects I have to declare a how I have to handle
them exactly.

thx a lot, if someone could give me a quite detailed response.

greez
masterphilch
 
Hi,

I know the code for a access database. I don't know if these is the same
code for a sql database. I don't have sql server on my computer.
 
Hi

I saw some connection-codes for access-databases, but they seem to be a
little different. Your code perhaps helps me to solve my problem.
 
I found the solution by myself:

Sub test5()
Dim qt As QueryTable
Dim sqlstring As String
Dim connstring As String
sqlstring = "Select * From *"
connstring = _
"ODBC;DSN=name_of_the_driver(individual);DATABASE=name_of_the_database;SERVER=ip_or_url;UID=user;PASSWORD=password"
With ActiveSheet.QueryTables.Add(Connection:=connstring, _
Destination:=Range("B1"), Sql:=sqlstring)
.Refresh
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top