View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sam Wilson Sam Wilson is offline
external usenet poster
 
Posts: 523
Default One connection multiple unique SQL's

Without seeing your code, you want something along these lines:


sub demo()


dim c as adodb.connection
dim rs as adodb.recordset
dim s as string

set c = new adodb.connection
c.Open "Provider= MSDASQL;Data source = {ODBC DSN name};Initial Catalog =
{your db};" & _
"user id={id};password = {pwd}"

'1st query
s = "select ..."
set rs = c.execute(s,,1)
..
..
..
rs.close

'2nd query
s = "select ..."
set rs = c.execute(s,,1)
..
..
..
rs.close

'etc

c.close

end sub


"Nelson" wrote:

Good day, in creating a my worksheets that have differing DB queries I
noticed that I have also created a different connection string each time.

Now when I update my 10 work sheets I am prompted for my password and DB
details 10 times

All connections are to the same DB only the queries are different, how can I
make it so that I am only asked once for the DB information then all the
sheets get updated?

Thanks
--
Nelson
--
Nelson