Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a code which is able to connect to my SQL server 2014. I am trying to check if a table already exist and if not i am trying to add the table based on an excel's column cell(named range)
VB
For each Row


When I step through the code, at
VB
Set rs = HITBTCupdate.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "table"))
I see that the first table in the Database is passed into rs(2).value.

The code continues and i am able to update the database based on my excel cells.

after HITBTCcmd.Execute within the code
VB
Next Row
I see rs(2).value still has the first table in the database and not the second table i have within the database. Which i assume i am not iterating through the
VB
rs
array.

What I have tried:

VB
Set rs = HITBTCupdate.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "table"))
HITBTCcmd.ActiveConnection = HITBTCupdate


For Each Row In rng
tblName = Row
    If rs(2).Value = Row Then
    HITBTCcmd.CommandText = GetinsertText
       
    Else
    HITBTCcmd.Execute "CREATE TABLE " & tblName & " ([Row] text(50) WITH Compression, " & _
                 "[Column1.ask] decimal(10) WITH Compression, " & _
                 "[Column1.bid] decimal(10) WITH Compression, " & _
                 "[Column1.last] decimal(10) WITH Compression, " & _
                 "[Column1.open] decimal(10) WITH Compression, " & _
                 "[Column1.low] decimal(10) WITH Compression, " & _
                 "[Column1.high] decimal(10) WITH Compression, " & _
                 "[Column1.volume] decimal(10))WITH Compression," & _
                 "[Column1.volumeQuote] decimal(10) WITH Compression, " & _
                 "[Column1.timestamp] Datetime(20) WITH Compression, " & _
                 "[Column1.symbol] text(10) WITH Compression,)) "


HITBTCcmd.CommandText = GetinsertText
HITBTCcmd.Execute

End If
Next Row

HITBTCupdate.Close

Set HITBTCupdate = Nothing


End Sub
Posted
Updated 6-Feb-18 0:52am
v3
Comments
Maciej Los 4-Feb-18 5:49am    
Sorry, but your question is unclear...

1 solution

 
Share this answer
 
Comments
Maciej Los 6-Feb-18 8:59am    
5ed!
RDBurmon 7-Feb-18 1:26am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900