Hi everyone, I am afraid that I have already asked this question in the past (or at least I knew an answer to it) but I am unable to do it now. I have an SQL Server data base. I used the GUI interface of odbcDriverConnect to create a .dsn file for this data base and every time I want to connect I invoke odbcDriverConnect() which opens GUI from which I choose my .dsn file and the connection is established. Now I want to do this automatically (without GUI) and all my attempts fail. If I remember correctly the dsn must be a string containing all the connection details but it does not work for me. Could anybody help, please! Thank you! Moshe.
On Wed, 13 Feb 2008, Moshe Olshansky wrote:> Hi everyone, > > I am afraid that I have already asked this question in > the past (or at least I knew an answer to it) but I am > unable to do it now. > I have an SQL Server data base. I used the GUI > interface of odbcDriverConnect to create a .dsn file > for this data base and every time I want to connect I > invoke odbcDriverConnect() which opens GUI from which > I choose my .dsn file and the connection is > established. > Now I want to do this automatically (without GUI) and > all my attempts fail. If I remember correctly the dsn > must be a string containing all the connection details > but it does not work for me.Clearly it does, as you did that via odbcDriverConnect. Look at the object it returns: it contains the string it used. You can use that directly.> > Could anybody help, please! > > Thank you! > Moshe. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Yes, it does - thank you!
The only thing I forgot (and it took me a while to
find this out) was to separate the fields by
semicolon, i.e. the correct command is:
odbcDriverConnect("driver=SQL Server;
database=dataBaseName; wsid=myComputer;
server=dataBaseServer; uid=moshe; pwd=moshe")
--- Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
> On Wed, 13 Feb 2008, Moshe Olshansky wrote:
>
> > Hi everyone,
> >
> > I am afraid that I have already asked this
> question in
> > the past (or at least I knew an answer to it) but
> I am
> > unable to do it now.
> > I have an SQL Server data base. I used the GUI
> > interface of odbcDriverConnect to create a .dsn
> file
> > for this data base and every time I want to
> connect I
> > invoke odbcDriverConnect() which opens GUI from
> which
> > I choose my .dsn file and the connection is
> > established.
> > Now I want to do this automatically (without GUI)
> and
> > all my attempts fail. If I remember correctly the
> dsn
> > must be a string containing all the connection
> details
> > but it does not work for me.
>
> Clearly it does, as you did that via
> odbcDriverConnect. Look at the
> object it returns: it contains the string it used.
> You can use that
> directly.
>
> >
> > Could anybody help, please!
> >
> > Thank you!
> > Moshe.
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> reproducible code.
> >
>
> --
> Brian D. Ripley,
> ripley at stats.ox.ac.uk
> Professor of Applied Statistics,
> http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865
> 272861 (self)
> 1 South Parks Road, +44 1865
> 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865
> 272595
>
Moshe, Thanks so much for the added comment, I had fallen into the exact same little syntax pitfall. Your clarification really helped! Jack Moshe Olshansky-2 wrote:> > Yes, it does - thank you! > The only thing I forgot (and it took me a while to > find this out) was to separate the fields by > semicolon, i.e. the correct command is: > > odbcDriverConnect("driver=SQL Server; > database=dataBaseName; wsid=myComputer; > server=dataBaseServer; uid=moshe; pwd=moshe") > > --- Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote: > >> On Wed, 13 Feb 2008, Moshe Olshansky wrote: >> >> > Hi everyone, >> > >> > I am afraid that I have already asked this >> question in >> > the past (or at least I knew an answer to it) but >> I am >> > unable to do it now. >> > I have an SQL Server data base. I used the GUI >> > interface of odbcDriverConnect to create a .dsn >> file >> > for this data base and every time I want to >> connect I >> > invoke odbcDriverConnect() which opens GUI from >> which >> > I choose my .dsn file and the connection is >> > established. >> > Now I want to do this automatically (without GUI) >> and >> > all my attempts fail. If I remember correctly the >> dsn >> > must be a string containing all the connection >> details >> > but it does not work for me. >> >> Clearly it does, as you did that via >> odbcDriverConnect. Look at the >> object it returns: it contains the string it used. >> You can use that >> directly. >> >> > >> > Could anybody help, please! >> > >> > Thank you! >> > Moshe. >> > >> > ______________________________________________ >> > R-help at r-project.org mailing list >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, >> reproducible code. >> > >> >> -- >> Brian D. Ripley, >> ripley at stats.ox.ac.uk >> Professor of Applied Statistics, >> http://www.stats.ox.ac.uk/~ripley/ >> University of Oxford, Tel: +44 1865 >> 272861 (self) >> 1 South Parks Road, +44 1865 >> 272866 (PA) >> Oxford OX1 3TG, UK Fax: +44 1865 >> 272595 >> > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- View this message in context: http://www.nabble.com/non-interactive-connection-to-SQL-Server-tp15474256p21758234.html Sent from the R help mailing list archive at Nabble.com.