Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default ODBC connection for insert into SQL Server

I'm able to do the following to SELECT from a SQL Server:

--

With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DRIVER=SQL Server;SERVER=myServer;UID=;APP=Microsoft Office
XP;WSID=myWorkstation;Trusted_Connection=Yes" _
, Destination:=newsheet.Range("A1"))
.CommandText = Array( _
"SELECT myData FROM myTable")

---snip ---

End With

--

I did this easily enough through Data/Import External Data.

How do I establish the same connection in order to do an INSERT into
the SQL Server? Can I do this through an ODBC connection?

For some reason I'm not able to create an ADODB.Connection object. I
do have Microsoft ADO Ext 2.7 added as a resource. Is there another
resource that I need? If so, how do I get it?

Thanks,

NS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default ODBC connection for insert into SQL Server

This might be a help for getting data to and from Excel and Access. It's
easily adaptable for SQL Server.

It includes examples of using variables in SQL queries.
http://www.bygsoftware.com/examples/sql.html

Or you can get there from the "Excel with Access Databases" section on page:
http://www.bygsoftware.com/examples/examples.htm

It demonstrates how to use SQL in Excel's VBA to:

* create a database,
* create a table and add data to it,
* select data from a table,
* delete a table,
* delete a database.

DAO and ADO files available.

You can also download the demonstration file called "excelsql.zip".

The code is open and commented.


--
Regards
Andy Wiggins
www.BygSoftware.com
Home of "Save and BackUp",
"The Excel Auditor" and "Byg Tools for VBA"



"nevada" wrote in message
om...
I'm able to do the following to SELECT from a SQL Server:

--

With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DRIVER=SQL Server;SERVER=myServer;UID=;APP=Microsoft Office
XP;WSID=myWorkstation;Trusted_Connection=Yes" _
, Destination:=newsheet.Range("A1"))
.CommandText = Array( _
"SELECT myData FROM myTable")

---snip ---

End With

--

I did this easily enough through Data/Import External Data.

How do I establish the same connection in order to do an INSERT into
the SQL Server? Can I do this through an ODBC connection?

For some reason I'm not able to create an ADODB.Connection object. I
do have Microsoft ADO Ext 2.7 added as a resource. Is there another
resource that I need? If so, how do I get it?

Thanks,

NS



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ODBC connection failed. Jim Moberg Excel Discussion (Misc queries) 0 October 9th 06 03:51 PM
ODBC connection failed. Jim Moberg Excel Discussion (Misc queries) 0 October 9th 06 03:48 PM
Broken ODBC Connection dsb Links and Linking in Excel 1 June 12th 06 11:47 PM
ODBC connection by udl Dorothy[_4_] Excel Programming 1 January 8th 04 05:32 PM
ODBC System DSN Connection Mark[_22_] Excel Programming 4 October 21st 03 10:12 AM


All times are GMT +1. The time now is 10:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"