Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / SQL Server / ADP / September 2003

Tip: Looking for answers? Try searching our database.

Connection To sql server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roy Goldhammer - 05 Sep 2003 23:21 GMT
Hello there

I need to create the connection to sql server by code.

Can i do this?

any help would be useful
Van T. Dinh - 05 Sep 2003 13:49 GMT
****Untested****
Dim cnn As ADODB.Connection

Set cnn = New ADODB.Connection
cnn.Open "Provider=SQLOLEDB; Server={YourServer};" & _
   "Database={YourDatabase};" & _
   "uid={UserName}; pwd={Password}"

'(above is for SQL Server Authentication)

Replace the last line with:

   "Trusted_Connection=Yes"

for MS Windows NT Authentication.

--
HTH
Van T. Dinh
MVP (Access)

> Hello there
>
[quoted text clipped - 3 lines]
>
> any help would be useful
Roy Goldhammer - 06 Sep 2003 03:30 GMT
Thankes Van

How can i do this for the currentProject.Connection?
> ****Untested****
> Dim cnn As ADODB.Connection
[quoted text clipped - 24 lines]
> >
> > any help would be useful
Van T. Dinh - 06 Sep 2003 23:04 GMT
I am not sure of your question but if you meant you want to create a
Connection Object in code which is the same as your ***ADP*** Connection
then simply use:

Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection

If you are using ***MDB***, the CurrentProject.Connection points to your
MDB, not SQL Server so it is of no help in this case.

Re-post with more details if I guessed incorrectly.

--
HTH
Van T. Dinh
MVP (Access)

> Thankes Van
>
> How can i do this for the currentProject.Connection?
Roy Goldhammer - 18 Sep 2003 06:14 GMT
Well Van.

The problem is this?

sometimes on my computer the connection to sql server is being stoped and i
need to reconnect it again.

The way i solve this so far is by entering to file -> Connect and reconnect
to sql server. After that i create a function that tests the connection to
sql server on any form i open and if the ADP is not connected it runs the
file -> connect menu automaticly. The problem is that i can work with this
but the client will never do such a thing like that

so my question is: can i do that the file -> connect menu order do with my
code: connectiog to sql server?

> I am not sure of your question but if you meant you want to create a
> Connection Object in code which is the same as your ***ADP*** Connection
[quoted text clipped - 16 lines]
> >
> > How can i do this for the currentProject.Connection?
Van T. Dinh - 18 Sep 2003 23:27 GMT
Can test at the moment but there is a command:

   DoCmd.RunCommand acCmdConnection

you may like to try (I never used it, though).

--
HTH
Van T. Dinh
MVP (Access)

> Well Van.
>
[quoted text clipped - 32 lines]
> > >
> > > How can i do this for the currentProject.Connection?
r - 06 Sep 2003 12:41 GMT
Once you have created the connection using the wizard, where do you find the
code you have listed below?

Thanks!

T

> ****Untested****
> Dim cnn As ADODB.Connection
[quoted text clipped - 24 lines]
> >
> > any help would be useful
Van T. Dinh - 06 Sep 2003 23:06 GMT
Are you talking about ADP?

If it is the case, use the Menu File / Connection ... to get the ADP
Connection.

--
HTH
Van T. Dinh
MVP (Access)

> Once you have created the connection using the wizard, where do you find the
> code you have listed below?
>
> Thanks!
>
> T
Joel_Banks - 15 Sep 2003 15:01 GMT
When I try to use the connection wizard, the SQL db connects for a flash and
then disconnects.  I have changed everything that I could in wizard.  Any
ideas?

Thanks in advance.

Joel Banks

> Are you talking about ADP?
>
[quoted text clipped - 13 lines]
> >
> > T
Van T. Dinh - 15 Sep 2003 15:32 GMT
Not sure but have you got appropriate permission to the SQL Server?

--
HTH
Van T. Dinh
MVP (Access)

> When I try to use the connection wizard, the SQL db connects for a flash and
> then disconnects.  I have changed everything that I could in wizard.  Any
[quoted text clipped - 21 lines]
> > >
> > > T
Joel_Banks - 15 Sep 2003 15:52 GMT
Yes I do, I can test the connection and it is okay.  Also, the ODBC link
works fine.

Thanks,

Joel

> Not sure but have you got appropriate permission to the SQL Server?
>
[quoted text clipped - 33 lines]
> > > >
> > > > T
Van T. Dinh - 15 Sep 2003 16:22 GMT
Sorry, got no ideas as Connection Wizard works fine for me to date.

--
HTH
Van T. Dinh
MVP (Access)

> Yes I do, I can test the connection and it is okay.  Also, the ODBC link
> works fine.
>
> Thanks,
>
> Joel
BJ Freeman - 16 Sep 2003 21:33 GMT
do you have any start up code that could effect this?

> When I try to use the connection wizard, the SQL db connects for a flash and
> then disconnects.  I have changed everything that I could in wizard.  Any
[quoted text clipped - 21 lines]
> > >
> > > T
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.