Strategies for distributing SQL-server-based application - sql-server

I have written an application in vb.net, based on SSCE. Now I need to shift in SQL Server Express because I need to run the application on Sharing (LAN) and several users need to access the database at the same time.
I am absolutely new to SQL Server. I need to know the following:
1) Do I create SQL Server DB by Adding New Item in my VS 2008? or they need to be created in SQL Server mgmt Express ONLY?
2) How do I distribute these database, same way like SSCE databses?
3) Can these databases be used like we use Access DBs in sharing (just put in the shared folder)?
4) If no to Question 3, how to set the connection string as I donot know the name of computer of the user who will install my application.
Thanks

To create a new database, the easiest thing would probably be to do
into SQL Server Management studio, open the instance of SQL Server
where the database will live, right click on the "Databases" folder
and select "New Database...". Once the database is there you can add tables and the like.
You will not distribute this database. Instead you will include a
connection string in your application that references this DB. All
data will live on a single instance.
No, you will not share this like you shared an Access Database. One
problem I have with Access is that the untrained masses are set
loose on the database to do as they please. I would give as few
people as possible access to the database. And when you give them access limit their permissions to the bare minimum they need. If you want someone to
change the data in there create an application that allows them to
modify table records as you see fit.
Take a look at this link for an explanation of how you should setup
your connection string. The connection string itself will not vary
between machines. You will just need to use the appropriate account
that has the appropriate access to the DB. You will also need to
make sure that the server where the DB is running is accessible.
Good luck!

Related

Duplicate localDB under SQL Servers on my laptop

I've been running into an issue recently when I attempt any tutorials that involve using a SQL database, entity framework, dapper, etc.
When it comes time to publish a database, or utilize an ORM, I'm given duplicate options for the same localdb under SQL Servers. Furthermore, then I attempt to publish, the database doesn't show up under the localdb that I've chosen.
I'm wondering how I go about removing the other SQL Servers and just having the one available.
If you look at the image below, the Browse option gives me two of the same LocalDbs. Plus I also get a 3rd one under \ProjectModels. I'm wondering what's causing this and how it can be fixed since no matter which one I choose, the sql database I attempt to publish doesn't show up within any of them.
My advice is not to use this method to publish the database. (right click to delete)
Please refer to this official documentation.
File-based databases like SQLite or SQL Server Express are designed to store their data in easily transferable files that can be served with your application/site.
"Copy to Output Directory" Property of the database file to "Copy if newer". Just point the address to it.
If you are using a server-based database like SQL Server, MySQL, etc., you need to make sure that the target machine/environment has the same database server installed, and you need to write a deployment script to append the pre-populated data files to the server. This might be troublesome for you.
You can also refer to these links. 1,2,3

Multiple user access database with Sql server

I have an access database that is stored on a network drive where all users access the one file. The database is linked to Sql server tables located in a local on site server. In my vba code my connection is to the access database. My question is I know it's possible to just connect to sql server from vba but all my queries are stored in Access, so will my code be able to run the queries from access if it's connected to Sql server or would I need to re-write all the queries? The problem we are having is that more than one user may be on the same record pulled up and they are overwriting each other's changes. Also a user may need to take the program on their laptop instead of having to remote in to their desktop at office. I was thinking I could just give them a copy each and that would solve the problem. Does anyone have any answers?
Just re-write the queries in SQL Server. It may be painful now, but it shouldn't be too bad, and down the road a bit, you'll be glad you moved everything to SQL Server (much faster, more stable, you're using a real DB, etc.)
You will want to pull all the queries into VBA and rewrite them with the appropriate parameters.

Write Access Client App for SQL Server 2005 Backend

I'm writing an inventory/payroll system, and I'm storing all the records on a remote server running SQL Server 2005 on Windows Server 2008 R2. I was wondering how I could start writing forms(very basic) in MS-ACCESS 2010 to upload things to the database. I just want to test it out to make sure that once I implement the entire database, things will work smoothly and without error. I want to figure out how to just make a single form that will be connected to the database, right now the form will just be a simple single text input with a submit button, that will be uploading barcodes(strings not images).
If I need to clarify anything, please just ask.
Thanks in advance for any help
Microsoft has tons of useful "Getting Started" articles.
This one explains how to connect to SQL Server: http://office.microsoft.com/en-us/access-help/import-or-link-access-to-sql-server-data-HA010341762.aspx
This one covers all sorts of forms: http://office.microsoft.com/en-us/access-help/CH010369205.aspx
Go there, you will find a lot that can help you with whatever you are going to do.
Make sure you have the SQL Client driver installed on the workstation where you'll be using MS Access. You can download it here (look for sqlcnli).
The simplest way to get started is to build an ODBC DSN. Access can then link to your SQL Server tables using that DSN. How to Create a DSN
In Access, Go to the "External Data" option and choose ODBC. Locate your DSN and then select which tables you want Access to be linked to.
After your linked tables are showing up in the tables list, click on one of the tables, go to the Create tab (2007, not sure about 2010) and choose Form. This should automatically create a form for you using the table you had selected when you clicked the Form button. There's no need to write code or add buttons to this form. The default form can do all CRUD operations as long as permissions for all CRUD have been granted to the username you used when you created your DSN.
Some developers prefer to use ADO (code only, no linked tables or form wizards) or Pass Through Queries to access SQL Server from Access. I can't really tell you what you should be using because it depends on so many different factors including (but not limited to) size of project, amount of records, skill level, personal preferences, etc.

Change Access link from SQL Server to another Access file?

I've seen lots of questions regarding moving data from Access to SQL Server, but I'd like to go the other route. Here's why:
I've been working on a sizable project with a SQL Server 2008 back-end and Access 2007 front-end. I'd like to be able to do some work on the front-end from home over the weekend, but I don't have access (VPN or otherwise) to SQL Server from there. I'd like to change my linked tables from SQL Server to another Access database file where I imported a snapshot of the SQL Server data. Then, come Monday morning, switch links back to SQL Server.
My problem is when I go to the Linked Table Manager and attempt to change the link, all I get is the ODBC Select Data Source dialog. If I try to link to an Access database, it tells me ODBC can't be used to link, import or export to another Access file.
One thought has occurred to me but I haven't tried yet; maybe someone could tell me if it's a good or bad idea: would I be able to delete the links, re-create them to the other Access file, and not lose any functionality in my queries/forms/reports?
My proposal would be to have SQLExpress (free) installed on your computer. You can then have all the data available on the machine. Create a publication on your main server, and have your local machine suscribe to this replication (if you don't need to save/synchronize the data changes done on your machine, you can stick to a basic 'snapshot' replication.)
You then just have to change your connection string from your network MSSQLSERVER to your localhost SQLEXPRESS server instance to have your app work.
If, for any reasons, you have to make changes to the database model while being off-line, you will then have to unsubscribe from the main server before making the changes on the local server. When you're back to the office, make sure that the same changes are done on the main server. My advice is to write your changes in T-SQL, save them in a file, and launch the file against the main server once you're back to work.
My opinion: don't work too much on weekends, or make sure your client is being billed for that.
For linking tables, you need to delete them and entirely and recreate them. Using the linked table manager to refresh ODBC links doesn't even work reliably when you're still using ODBC, as there is data cached in the table link definitions that doesn't get refreshed (e.g., if you change the number of columns in a SQL Server view, refreshing the table link with Linked Table Manager will update the number of columns, but you won't necessarily get an updateable view (assuming the original was updateable)).
But it's not clear whether or not you'll lose functionality or not. That all depends on how much of your application's logic is server-side, in SQL Server views and stored procedures. None of those will work if you link to a Jet back end.

How to Select data from Table from a DSN in T-SQL?

How can I get data from a database that I can only access through an ODBC Data Source (DSN) in T-SQL MS SQL Server, any version?
After reading the following, I decided to create SSIS packages to get data from another data source via DSN.
With Linked Servers, you have a little
more flexibility, but also some
additional security concerns. You are
linking to the other data source as a
specific user, with that user's
authority to the linked server. If
all you need is Read-only access to a
few views, that user should only be
granted that authority to those
objects. This isn't so bad, you have
total control of the authority you
grant to that user, but you have to
manage it and realize that granting
too much authority could be a security
concern.
Consider using a linked server with
read-only rights to copy data from
specific tables/view into permanent
tables in the other database in lieu
of an SSIS package. You can execute a
job periodically to copy the
appropriate data from the linked
server to the local database and
reference the local tables within your
application. It will likely be easier
to implement and maintain than an SSIS
package, and could potentially be
updated later to make it a live
solution.
Source
The selecting is the easy part, but the real question is how do you connect to the datasource.
First, where are you selecting data from? Are you writing code, or just using the Query analyzer tool (2000) or Management Studio (2005)?
You'll need to setup your connection to the database regardless. If you need help with the connectionstrings to a DSN, the site www.connectionstrings.com is very helpful. Otherwise, from a query tool there will be dialog boxes or wizards to help you.
You need to add a Linked Server to the source, then you can query it as usual.

Resources