Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
emyk
Yak Posting Veteran
57 Posts |
Posted - 2012-04-04 : 23:07:06
|
I am working on excel spreadsheet upload process where users export their data via macro VBA into SQL SERVER 2005.So far I am able to import data from the SQL server into an execl but I am being challenged with writing excel data into SQL SERVER database:Here is what I am working on Sub Connect2SQLXpress() Dim oCon As ADODB.ConnectionDim oRS As ADODB.Recordset Set oCon = New ADODB.ConnectionoCon.ConnectionString = "Driver={SQL Native Client};Server=myserver;Database=DB; Trusted_Connection=yes;"oCon.Open Set oRS = New ADODB.RecordsetoRS.ActiveConnection = oConoRS.Source = "insert into table (ID,Name,State,Code) VALUES (Columns("A":"B":"C":"D"))"oRS.Open oRS.Close oCon.Close If Not oRS Is Nothing Then Set oRS = NothingIf Not oCon Is Nothing Then Set oCon = NothingMsgBox "All done!"End Sub |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-04 : 23:21:29
|
why not use OPENROWSET or export import wizard for this?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-04-17 : 03:51:08
|
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926MadhivananFailing to plan is Planning to fail |
|
|
Webtalk
Starting Member
2 Posts |
Posted - 2012-10-11 : 00:53:15
|
I've learn some excellent stuff here.unspammed |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
|
|
|
|