Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88066

Excel VBS ERROR: relation "andmebaas" does not exist

$
0
0

I am using Excel 2019 Home and Business

I have built SQL string what works if I use it trough PGAdmin, but if I execute it trough vbs i get relation error. This is how I create connection

db.Open "DSN="& databaseSource & "; Database="& databaseName & "; Uid="& databaseUsername & "; Pwd="& databasePassword
cmd.CommandType = adCmdText
    cmd.ActiveConnection = db

this is the SQL string I am trying to execute. Same string works if used trough PGAdmin

strSQL = "INSERT INTO public.kaup (grupp2, nimi, yhik, viit, grupp1, algyhik, suurus, kaal, baasyhik, tootjamaa, taimoot, teema, varvikood, brand, liik,  nimetus, tellitav, varviryhm, kollektsioon) VALUES ("& setT("brand") & ", "& Chr(39) & setName & Chr(39) & ", "& setT("unit") & ", "& setT("isRecipe") & ", "& setT("mainGroupNr") & ", "& setT("algyhik") & ", "& setT("size") & ", "& totalWeightStr & ", "& setT("baasyhik") & ", "& setT("origin") & ", "& setT("taimoot") & ", "& setT("season") & ", "& setT("factoryColor") & ", "& setT("categoryNr") & ", "& setT("productTypeNr") & ", "& setT("factoryName") & ", "& setT("orderable") & ", "& setT("colorGroup") & ", "& setT("collection") & ")"
    cmd.CommandText = strSQL
    On Error GoTo errorHandler
    cmd.Execute

String looks like this:

INSERT INTO public.kaup (grupp2, nimi, yhik, viit, grupp1, algyhik, suurus, kaal, baasyhik, tootjamaa, taimoot, teema, varvikood, brand, liik,  nimetus, tellitav, varviryhm, kollektsioon) VALUES (186, 'Nord Active Plus Set Safari + Granite Chassis', 'TK', 1, 2, 'tk', 'N/A', 9.5, 'PCE', 'PL', 'ZZZ', '2020', 166, 2, 885, 'Nord Active Plus Set', 1, 15, null)

I assume I need to add some tables in SQL string, but how would I do that in vbs? The Table andmebaas is located in 3 different schemas.

Also I removed one another problematic column because in Database it has this written in Create table.

If i add k_m_vaba in my code ith will say it has no relation to kaup_kaibemaks

CONSTRAINT kaup_kaibemaks FOREIGN KEY (k_m_vaba)
        REFERENCES eesti.kaibemaks (kaibemaks) MATCH SIMPLE
        ON UPDATE CASCADE
        ON DELETE RESTRICT
        NOT VALID,

How do I add more connections or relations in my SQL string so that when INSERT new row It knows where are these tables located at?


Viewing all articles
Browse latest Browse all 88066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>