melvincast
New Member
- Joined
- Jun 9, 2015
- Messages
- 3
i got this code , i want to copy this table to a temporal table in SQL server, and if the temporal table exist, i want to drop ip and create again, some help please, This connection code is usefull.
<colgroup><col><col><col><col><col><col><col><col span="3"></colgroup><tbody>
</tbody>
Version | Tipo Metrica | Dimension GR | Metrica | Ejercicio | Periodo | Jerarquia | AP | AA | Plan |
1 | as | gr | ventas | 2014 | 1 | gr | 1600 | 1800 | 2000 |
1 | as | gr | ventas | 2014 | 1 | gr | 1600 | 1800 | 2000 |
1 | ds | gr | ventas | 2014 | 1 | sdo | 650 | 700 | 650 |
1 | sa | gr | compras | 2014 | 1 | sdo | 750 | 800 | 800 |
2 | re | gr | compras | 2015 | 2 | sde | 550 | 600 | 600 |
2 | re | gr | compras | 2015 | 2 | gr | 2000 | 2500 | 2300 |
2 | as | gr | ventas | 2015 | 3 | LS | 450 | 600 | 550 |
<colgroup><col><col><col><col><col><col><col><col span="3"></colgroup><tbody>
</tbody>
Code:
Public Function RecordsetFromSheet()
Dim cn As Object
Dim rs As Object
Set cn = CreateObject("ADODB.Connection")
cn.ConnectionString = OleDbConnectionString("xxxxx", "xxxx", "xx", "xxxxxxxxxx")
cn.Open
If CBool(cn.State And adStateOpen) = True Then
cn.Close
Set cn = Nothing
End If
rs.Close
cn.Close
Set cn = Nothing
End Function
Function OleDbConnectionString(ByVal Server As String, ByVal Database As String, _
ByVal UserName As String, ByVal Password As String) As String
If UserName = "" Then
OleDbConnectionString = "Provider=SQLOLEDB;Data Source=" & Server _
& ";Initial Catalog=" & Database _
& ";Integrated Security=SSPI;Persist Security Info=False;"
Else
OleDbConnectionString = "Provider=SQLOLEDB;Data Source=" & Server _
& ";Initial Catalog=" & Database _
& ";User ID=" & UserName & ";Password=" & Password & ";"
End If
End Function