Multiuser SQL Powered Access Database Over Network - sql-server

I have been creating an access database for my assignment. I am using SQL Server 2014 for the datasource for the access tables. Now the problem is that according to the assignment
I need to make the db multiuser over network
it has to be an accde file
In short, how can I connect to SQL Server when I deploy the database on my college pc. And how to make the accde work on my school network where the SQL Server is not the one I am using at my personal machine.
It is a simple book entry database containing few tables including print button and picture of book attachment.

Use a DSN-less connection. Provide a function that changes the connection string on all linked tables.
See Linked table ms access 2010 change connection string
or Changing SQL connection information for DSN-less Access frontend
You don't want each user having to enter the server information into the frontend. So take your frontend to the school network, run the function to re-link all tables, then create the .accde, then distribute it.

If the sql server is on your same network, then all you have to do is link your tables to the production sql server. You then crate the accDE, and that can be deployed to any machine.
Access by “default” creates a DSN less connection. So if you follow the defaults when linking to sql server (use a FILE dsn), then once access links to those tables, access “converts” the DSN to a DSN less connection for you.
What this means is that you do not need any VBA re-linking code. When using a file dsn, access converts these to DSN less for you. Once linked, then Access ignores and does not use nor require the original DSN.
So your steps are:
Linking to the production SQL server on the network. Just make sure you use the “default” file dsn.
Once you are sure the accDB works with that production SQL server, you can then compile/create the accDE. That accde will now function on ANY workstation (and this work since access by default creates and uses and makes a DSN less connection for you).
You do NOT need any VBA re-link code.
You do NOT have to write some VBA code to create a DSN less connection (access does this automatic for you).
Of course, during this re-link process, your computer will have to be on the same network with the production SQL server you plan to link to.
If you were some off site worker, and you cannot be on the same network during the re-link process, then YES you would have to adopt some VBA code to re-link for you. However, if you can be on the same network during this re-link process, then at that point you can create the accDE file, and it can be distributed to any workstation on that network without further configuration.
About the only issue would be to ensure that you link to this production server using the standard and legacy “SQL Server Driver” as your linking choice. You can use the later “native 11” etc. drivers, but they are not installed by default on each version of windows and thus this ODBC driver may well not be installed on each workstation (but the standard SQL Driver is installed by default.
Again:
You do not need some VBA code or re-link code to create a DSN-less connection. Access by default when choosing a “file” DSN will create DSN-links for you – you thus don’t need any special re-link code, nor do you need some VBA re-link code to achieve DSN-less links.

Related

Connect to linked server (Oracle) in SQL Server using Instant Client

I need to connect to a remote database (Oracle) using a MS SQL Server (2019) linked server. What I did so far:
Installed Oracle Instant Client x64 and the ODBC drivers on the machine where the SQL server is running
Created a symlink to the central TNSNAMES.ORA (on a file share in the network) inside the Oracle Instant client folder.
Set the necessary environment variables
Created an ODBC connection to the database on the Oracle server on this machine
Restarted MS SQL Server
Created a linked server (Microsoft OLEDB Provider for ODBC Drivers) in the SQL instance
When connecting to the SQL Server using sqlcmd on this machine (I did not install SSMS there), I can query the linked database using OPENQUERY(). I can also read the file TNSNAMES.ORA using this command (note, the given file is the symlink, but it displays the contents of the linked file, as it should):
SELECT * FROM OPENROWSET(BULK 'C:\InstantClientx64\tnsnames.ora', SINGLE_CLOB) TNSNames
So far, everything is fine.
Now, when I connect to the SQL Server from my workstation using SSMS, i get the following error when trying to read TNSNAMES.ORA using the command above:
Cannot bulk load because the file "C:\InstantClientx64\tnsnames.ora" could not be opened. Operating system error code 5(Access is denied.).
I created a file test.txt in the instant client folder containing something like "Am I allowed to read this?" - and I was, no problems.
I started procmon on the server to find out what happens. When using the above command on the SQL server, I get a REPARSE (because it's a link!), and then SUCCESS, the file is displayed in the sqlcmd console.
When using this command in SSMS (on my local workstation), first appears the REPARSE (OK), then ACCESS DENIED.
In both cases it is the same user account which is displayed as "Impersonating" in the procmon's details. There is definitely no problem with a firewall, and the read permissions on the tnsnames.ora file on the network share are granted for Everyone. I am also able to create an ODBC item on the local workstation, and can connect and query the database from here.
I have done this in the past I don't know how often, and never had problems. What am I missing?
Why are you trying to read the tnsnames.ora file via SQL? The Oracle libraries will (should) internally open it and use it when your app connects to the DB.
The default location for network config files is shown in the Instant Client installation doc. In your case it will be C:\InstantClientx64\network\admin. Unless you have set the TNS_ADMIN variable, then start by creating this subdirectory and putting tnsnames.ora in it.
(A future version of Instant Client on Windows will create the network\admin subdirectory automatically, similar to the way it is created with the Linux Instant Client packages).

Connecting to DB2 through ODBC is extremely slow

I am experiencing extremely slow connections to a local DB2 (v9.7 Express-C) database through ODBC on a Windows 7 system (x64). I wrote several test programs, each connecting to a local database for 100 times in a row (without querying) and measuring the time. Results are:
C++ x86 DB2/ODBC: 32bit C++ application, connecting to a local DB2 database via CDatabase
C++ x86 DB2/ODBC: same as above, but x64 application
PHP DB2/ODBC: Connecting to a local DB2 database via odbc_connect.
PHP MySQL/ODBC: Connecting to a local MySQL database via odbc_connect.
JDBC DB2: Java application, connecting to a local DB2 database using the DB2 JDBC driver.
JDBC MySQL: Java application, connecting to a local MySQL database using the MySQL JDBC driver.
My first thought was that something's wrong with my ODBC configuration, but as you can see connecting to a MySQL database through ODBC works like charm. On the other hand, connecting to DB2 with the JDBC driver instead of ODBC works fine too (although it's still a lot slower than MySQL).
I found this related question, but it does not apply to me.
Any hints on what might be causing this and how to resolve would be great!
Supplementary question: What are common connection times when connecting to a DB2 database through ODBC? Is it normal for the DB2 ODBC driver to be so slow?!
One thing that you should look at is the database activation. DB2 activates the database upon the first connection and deactivates it when the last connection is closed. During activation DB2 allocates transaction log files, memory pools, and performs a number of other tasks that take time.
This behaviour does not depend on the type of connection (ODBC or JDBC); the difference you observe might be explained by an extra connection that keeps the database active during your JDBC tests.
Try issuing ACTIVATE DB <YOURDB> before your tests, which will keep the database active even in the absence of connections. There is no way to activate databases by default, apart from issuing this command upon the system startup, e.g. from a batch file.

Problems faced in keeping SQL Compact Edition Database on another machine in same network

I am using SQL CE 3.5 for one of my project, the front end is WPF application which process the given files and dumps the data to SQL CE database.
Presently application and DB is on same machine.
Client wants that he should be able to run the application from any machine on the network but database should remain on shared location of Server.
User will select the path to SDF file in the Application and then when any file is processed application will dump the data to database.
My question is, if keep SDF file on network shared location and access it from any machine then does it will work fine or could give problem?
actually, it is not possible - SQL CE does not support network-hosted operations: everything related to the sdf-file (temp data) is recorded to the local machine, not network source, thus server is unable to process requests correctly.
You can use SQL Express Server that acts like data storage, for the local client the only thing you need is Microsoft Synchronization library 2.1 (it also works with SQL CE 4.0 SP1)
Summarising, create the SQL CE database, fill it with tables, index them, then port it to SQL Server express, add sync module to your app (in a separate thread ofc) and that's it.
Another solution is to use MS Access DB, which allows such mess, but it is incredibly slow not to mention no way to allow simultaneous writing to the db.

Linking Oracle with SQL Server

I'm trying to link SQL Server 2005 to an Oracle 10g database. I've installed the Oracle client on the SQL server and validated that I can connect to the Oracle database using both tnsping and sqlplus. When I try to run a query in SQL Server I get the following:
OLE DB provider "OraOLEDB.Oracle" for linked server "ORA_CSSA2APD" returned message "ORA-12154: TNS:could not resolve the connect identifier specified".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "OraOLEDB.Oracle" for linked server "ORA_CSSA2APD".
Any ideas? I've tried both of the following queries with no luck:
select * from openquery(ORA_CSSA2APD, 'select count(rowid) from eservice_op.agent')
select count(rowid) from ORA_CSSA2APD..eservice_op.agent
I suspect an environment setting. That is, your session is picking up the TNSNAMES.ORA file but the session underlying SQL Server is not. I'd check were ORACLE_HOME and, possibly, TNS_ADMIN are being set and pointing to.
Are you able to use the easy connect syntax for the database with the SQL Server connection .
IE replace ORA_CSSA2APD with hostname:1521/service_name
ORA:12154 generally means that the alias of the db you're trying to connect to wasn't found in the tnsnames.ora file. (See http://ora-12154.ora-code.com/ a more detailed explanation.)
You need to make sure that the Data Source is an alias that the tnsnames file knows about (on the server where SQL Server resides, regardless of where you're running the queries from); SQL Server is going to be just like any other Oracle client and needs to know where to connect to and without the tnsnames.ora file, it's not going to know the details of where the Oracle db is.
If you don't have access to the SQL Server server (there's one from the department of redundancy department), you'll need to get the server admin to set that up for you.
(The Data Source property of the linked server should be the alias in tnsnames.ora alias for the db you're trying to link to.)
HTH...
TNS error messages generally means the connection is flawed (eg host is unobtainable/timesout on the specified port, or that is simply doesn't know what ORA_CSSA2APD is supposed to point to).
One thing to consider is, are you using a 64-bit Windows and are you using a 32-bit or 64-bit Oracle client (or possibly both). If you've got a 32-bit app running on a 64-bit OS trying to call Oracle, it needs a 32-bit Oracle client. Using a 32-bit client on a 64-bit OS can be tricky and it is safer to NOT install it in the "Program Files (x86)" folder.
Also bear in mind the following
In a 64-bit version of Windows Server
2003 or of Windows XP, the
%WinDir%\System32 folder is reserved
for 64-bit applications. When a 32-bit
application tries to access the
System32 folder, access is redirected
to the following folder:
%WinDir%\SysWOW64
So for 64-bit windows, the 32 bit stuff is in the SysWOW64 folder and the 64 bit stuff is in the system32 folder.
This issue happened to me, as well, but only with certain Windows user accounts. A combination of enabling the "Allow inprocess" provider option for the OraOLEDB.Oracle provide (SSMS > Server Objects > Linked Servers > Provides > OraOLEDB.Oracle), restarting the SQL Server Windows service and lastly adjusting the permissions on the TNSNAMES.ora file directly.
We found that SQL Server, for some unknown reason, started looking for the TNSNAMES.ORA file in default Oracle locations.
We were able to place the TNSNAMES.ORA files in the following locations, with successful results:
For SQL Server 32-bit on 32-bit OS or 64-bit on 64-bit OS
%ProgramFiles%\Oracle
%ProgramFiles%\Oracle\network\admin
For SQL Server 32-bit on 64-bit OS
%ProgramFiles% (x86)\Oracle
%ProgramFiles% (x86)\Oracle\network\admin
We too were able to connect using SQL*Plus, but SQL Server could not. It is important to note that SQL*Plus did not use the same TNSNAMES.ORA file. This is why one worked.

Basic Questions about SQL Server Compact Edition 3.5

1) Is SSCE (SQL Server Compact Edition) a local only database? Meaning I can't access it from anywhere else but the host machine?
2) It supports up to 256 connections locally?
3) Are there any good tools available for converting an empty mdf with no stored procedures or triggers to a CE sdf?
4) When you run the install for this, does it open any ports at all? I wouldn't think so but my boss is convinced it does.
5) Does SQL Server Management Studio open any ports by default upon installation?
Thanks for reading and any insight you can provide :)
Yes. It is a local only DB, and cannot be accessed from other machines
Not sure, I've never hit a
limit, but I know that there is a
4GB limit on the file size
None that I'm aware of
Again, none that I'm
aware of (at least my software and
corporate firewalls haven't been
complaining)
Again, none that I'm
aware of. The Management Studio
itself is not the DBMS package
(which does require some ports to be
opened). That said, I've never tried
to install the Management STudio
without either SQL DEVELOPER or SQL
EXPRESS.
Just a note: I answered Question #1 on the concept of attempting to use the SSCE as a SERVER which a secondary computer attaches to, as opposed to mounting the DB File from a Shared Drive. For example, in SQL Express, I can place an instance onto a server, and have multiple applications connect to it, and I can also mount the file associated with a DB into my local instance of SQL Express from a shared drive. In SSCE, one can mount the file, but can't act as a server.
the database file (normally an sdf) can happily be on a remote share but only one remote machine can access it at a time.
It supports 256 connections which can be from different processes.
Don't know sorry - I have used this project with some minor edits to copy from sql server effectively.
When installing from the package it might try to ping the windows update service for an up to date check (I haven't checked) when running via an xcopy deployment I see no open ports (you do not need to install SqlServerCE, simply placing the required dll in your private bin path (normally the same folder as the executable) is sufficient.
I don't know
As to the open ports the best way to check is simply to do an install with something like wireshark running.

Resources