MS Access Forum / Modules / DAO / VBA / June 2005
Setting up DSN through Code
|
|
Thread rating:  |
Mark A. Sam - 25 Jun 2005 02:17 GMT I am considering writing and distributing a small Access app which links to an SQL database through the internet and wonder how the application can set up a DSN on the users machine and link the necessary tables. Is there some code that someone can give me to accomplish this?
Thanks and God Bless,
Mark A. Sam
Duane Hookom - 25 Jun 2005 05:11 GMT You can make sure a reference is set to the DAO object library and use the RegisterDatabase method. You can also use vbscript to create DSNs by creating registry entries.
 Signature Duane Hookom MS Access MVP
>I am considering writing and distributing a small Access app which links to > an SQL database through the internet and wonder how the application can [quoted text clipped - 6 lines] > > Mark A. Sam Douglas J. Steele - 25 Jun 2005 12:52 GMT Why not go DSN-less? I've got sample code at http://www.accessmvp.com/djsteele/DSNLessLinks.html
(The site above also has a of link for creating a DSN programmatically)
 Signature Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!)
>I am considering writing and distributing a small Access app which links to > an SQL database through the internet and wonder how the application can [quoted text clipped - 6 lines] > > Mark A. Sam Mark A. Sam - 25 Jun 2005 13:32 GMT Hello Doug,
Are you saying your procedure will address a remote server through the internet? Who does it know where the server is located?
God Bless,
Mark
> Why not go DSN-less? I've got sample code at > http://www.accessmvp.com/djsteele/DSNLessLinks.html [quoted text clipped - 11 lines] > > > > Mark A. Sam Douglas J. Steele - 25 Jun 2005 14:43 GMT All I'm saying is that if you can connect using a DSN, you almost certainly can connect using a DSN-less connection string.
Take a look at Carl Prothman's site (there's a link to it on my page) http://www.carlprothman.net/Default.aspx?tabid=90#ODBCDriverForSQLServer
He says to connect to SQL Server running on a remote computer (via an IP address), use
oConn.Open "Driver={SQL Server};" & _ "Server=xxx.xxx.xxx.xxx;" & _ "Address=xxx.xxx.xxx.xxx,1433;" & _ "Network=DBMSSOCN;" & _ "Database=myDatabaseName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword"
Where: - xxx.xxx.xxx.xxx is an IP address - 1433 is the default port number for SQL Server. - "Network=DBMSSOCN" tells ODBC to use TCP/IP rather than Named
That means you'd need to modify the function declaration in my code from
Sub FixConnections(ServerName As String, DatabaseName As String)
to something like
Sub FixConnections( _ ServerName As String, _ DatabaseName As String, _ IPAddress As String, _ UserName As String, _ Password As String _ )
and the section
tdfCurrent.Connect = "ODBC;DRIVER={sql server};DATABASE=" & _ DatabaseName & ";SERVER=" & ServerName & _ ";Trusted_Connection=Yes;"
to something like
tdfCurrent.Connect = "ODBC;Driver={SQL Server};" & _ "Server=" & ServerName & ";" & _ "Address=" & IPAddress & ",1433;" & _ "Network=DBMSSOCN;" & _ "Database=" & DatabaseName & ";" & _ "Uid=" & Username & ";" & _ "Pwd=" & Password & ";"
 Signature Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!)
> Hello Doug, > [quoted text clipped - 21 lines] >> > >> > Mark A. Sam Mark A. Sam - 25 Jun 2005 15:14 GMT Doug,
The connect property doesn't reference an IP address, and thus can't locate the server. I don't know if what I am seeking can be accomplished with a DSN-less connection.
God Bless,
Mark
> All I'm saying is that if you can connect using a DSN, you almost certainly > can connect using a DSN-less connection string. [quoted text clipped - 73 lines] > >> > > >> > Mark A. Sam Douglas J. Steele - 25 Jun 2005 16:58 GMT How does the DSN know where the database is, then, if it doesn't use an IP address?
DSNs are strictly registry entries. Take a look in either HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI or HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI (depending on whether it's a System or User DSN) and see what it's actually got there.
 Signature Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!)
> Doug, > [quoted text clipped - 89 lines] >> >> > >> >> > Mark A. Sam David C. Holley - 25 Jun 2005 16:13 GMT So if I were to use SQL Server for the backend for a website, I could connect to the db using an Access frontend on my laptop?
> Why not go DSN-less? I've got sample code at > http://www.accessmvp.com/djsteele/DSNLessLinks.html > > (The site above also has a of link for creating a DSN programmatically) Douglas J. Steele - 25 Jun 2005 16:54 GMT I've never tried to connect to a SQL Server on the web, but theoretically using the connection string I posted elsewhere in this thread should work.
 Signature Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!)
> So if I were to use SQL Server for the backend for a website, I could > connect to the db using an Access frontend on my laptop? [quoted text clipped - 3 lines] >> >> (The site above also has a of link for creating a DSN programmatically) Rick Brandt - 25 Jun 2005 16:59 GMT > So if I were to use SQL Server for the backend for a website, I could > connect to the db using an Access frontend on my laptop? If the port that ODBC uses were left open to the internet, yes. That is not a recommended approach for security reasons though.
 Signature I don't check the Email account attached to this message. Send instead to... RBrandt at Hunter dot com
David C. Holley - 26 Jun 2005 01:28 GMT I thought there might be some security issues (it is afterall a Microsoft product). What then is the recommended approach?
>>So if I were to use SQL Server for the backend for a website, I could >>connect to the db using an Access frontend on my laptop? > > If the port that ODBC uses were left open to the internet, yes. That is not a > recommended approach for security reasons though. Rick Brandt - 26 Jun 2005 02:11 GMT >I thought there might be some security issues (it is afterall a Microsoft >product). What then is the recommended approach? Apps that run in web browsers mostly. As others have stated you can use remote session software with VPNs if your target user audience is fairly small.
Mark A. Sam - 26 Jun 2005 17:35 GMT Rick,
Is a table linked to an SQL Database through the web a security issue if the database is open, but not the tables?
God Bless,
Mark
> > So if I were to use SQL Server for the backend for a website, I could > > connect to the db using an Access frontend on my laptop? > > If the port that ODBC uses were left open to the internet, yes. That is not a > recommended approach for security reasons though. David C. Holley - 26 Jun 2005 17:49 GMT Actually, I think that the question at hand is wether or not its possible to have a linked table to a SQL Server database where the connection is made securly over the internet. (or in short) Is it possible to securly connect to a SQLServer database?
> Rick, > [quoted text clipped - 13 lines] > >>recommended approach for security reasons though. Mark A. Sam - 26 Jun 2005 19:52 GMT David,
I am connected to an SQL Database with linked tables. It is liked being locally connected. Whether it is secure, I don't know. I'd like to know if just being linked presents security issues.
God Bless,
Mark
> Actually, I think that the question at hand is wether or not its > possible to have a linked table to a SQL Server database where the [quoted text clipped - 18 lines] > > > >>recommended approach for security reasons though. Rick Brandt - 26 Jun 2005 21:28 GMT > David, > > I am connected to an SQL Database with linked tables. It is liked > being locally connected. Whether it is secure, I don't know. I'd > like to know if just being linked presents security issues. The link is irrelevent. Everything on the Access end is irrelevent. The fact that you CAN link means that the SQL Server port is exposed to the internet and could potentially be hacked into. How big the threat is I can't say. I only know that I was forced to re-write an app to use HTTP requests instead of linking to our SQL Server because of the security threat. Our sys admin had monitoring tools that showed that our SQL Server port was being "tested" hundreds of times a week.
 Signature I don't check the Email account attached to this message. Send instead to... RBrandt at Hunter dot com
David C. Holley - 27 Jun 2005 00:59 GMT I was suspecting that that might be an issue - that thanks to MS, its almost an all or nothing deal. DARN.
>>David, >> [quoted text clipped - 9 lines] > monitoring tools that showed that our SQL Server port was being "tested" > hundreds of times a week. David C. Holley - 27 Jun 2005 01:01 GMT Did you do anything with replication? I did think about migrating my website backend to SQLServer and then set things up where a replica sat on my laptop to xfer data gathered from the web and data entered on the laptop.
>>David, >> [quoted text clipped - 9 lines] > monitoring tools that showed that our SQL Server port was being "tested" > hundreds of times a week. Mark A. Sam - 27 Jun 2005 02:37 GMT Hello David,
I have never used replication. I never would. I looked it at one time becuase a client wanted to try it, but I convinced him not to. It seemed like it would have too many problems associated with it.
God Bless,
Mark
> Did you do anything with replication? I did think about migrating my > website backend to SQLServer and then set things up where a replica sat [quoted text clipped - 14 lines] > > monitoring tools that showed that our SQL Server port was being "tested" > > hundreds of times a week. Mark A. Sam - 27 Jun 2005 01:23 GMT > > David, > > [quoted text clipped - 5 lines] > that you CAN link means that the SQL Server port is exposed to the internet and > could potentially be hacked into. Thanks for the information, I was worried about that and thought I would have to rethink my methods. I am on a hosted server, so it isn't my problem.
How big the threat is I can't say. I only
> know that I was forced to re-write an app to use HTTP requests instead of > linking to our SQL Server because of the security threat. Our sys admin had > monitoring tools that showed that our SQL Server port was being "tested" > hundreds of times a week. I wonder of Oracle opens a server up to the same threat?
David C. Holley - 27 Jun 2005 00:57 GMT And that is the same question that I have.
> David, > [quoted text clipped - 31 lines] >>> >>>>recommended approach for security reasons though.
|
|
|