473,411 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Deploying a database

How i can i deploy and attach a database from a C# project. I created
the database in sql manager now i want to deploy it using a C# project
is this possible
Sep 30 '08 #1
1 2746
<ki*******@gmail.comwrote in message
news:14**********************************@u65g2000 hsc.googlegroups.com...
How i can i deploy and attach a database from a C# project. I created
the database in sql manager now i want to deploy it using a C# project
is this possible
Assuming that Sql Server is already installed on the computer where you
want to deploy the database, you have at least these options:

1) You can attach the database. This would require dettaching it from the
original server (or stopping the Sql Server) and copying the .mdf and .ldf
files. You would then transfer those files to the computer where you want
them deployed, and attach them to the local sql server by means of the
adequate call to the sp_attach_db stored procedure which is documented in
the Sql Server manuals. Of course, you can do this from C# by means of the
ExecuteNonQuery method of a SqlCommand.

2) If you are using Sql Server Express, and you want the database for local
use in single-user mode, you can use the "user instance" mode of sql server.
This doesn't require you to program anythig in your C# code (except copying
the mdf file), you just have to edit your connection string so that it uses
the necessary parameters for this mode of operation and contains the path to
the copied mdf.

3) You can use a backup. Extract the backup with Sql Manager, copy it to the
deployment media, and restore it with a "Restore Database..." Sql query with
adequate parameters. Of course, this query can be sent from C# with a
SqlCommand and ExecuteNonQuery.

In all three cases, you get the database on the deployment computer, but
you still have to worry about security, because the database users contained
in the database are mapped to sql logins in the original Sql Server, not in
the deployment Sql Server. You can create users and grant permissions once
again by sending the corresponding Sql calls with a SqlCommand. This is not
needed if you are using a user instance, which always maps the current user
to the dbo of the database.

Sep 30 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: damjanu | last post by:
Hi; I have spent some time investigating this issue, and I would like to verify with you my findings. I would greatly appreciate someone experianced saying yes to what I concluded, or no and...
1
by: Mister_d | last post by:
When deploying a solution using the Access 2003 runtime engine, do you have to use the packaging wizard that comes with the Access 2003 Developer Extentions, or can you use other packaging software...
1
by: K Meyer | last post by:
Everything in the deployment works fine with the exception of the address of the database also deployed on the remote server. The string address is found under "oledbconnection" in the ".......
8
by: bigjmt | last post by:
Hi all, I'm new to this. This will be my first setup for a web app I created. I created a web app(form) in vb.net on my test machine. Now I want to host this solution on a web server machine. I...
0
by: sai | last post by:
hi all, i am working on a database project. How i can connect to a database at the time of deploying my application on a system. regards, sai.t
1
by: rcoco | last post by:
hi, I have managed deploying my database and I've created .msi but it's on my computer. I've tryed to copy it on a different server using copy and paste but it cannot do it. how could I go about...
3
by: pooba53 | last post by:
I have a VB .NET 2003 application that communicates with an Access db. I am deploying the application using the Wizard that creates an install package and it IS properly grabbing the Access db and...
7
by: harry | last post by:
I've set my database connection as an Application.Setting using the designer. Since Application.Settings are read only, how do I change the connection properties when deploying to another...
0
by: sanjaypasumarty | last post by:
Hello, I am facing issues when i am deploying application on WebSphere Process server. The appplication is not deploying successfully and showing some DB2 errors in the logs. We are unable to find...
1
by: wastebrain | last post by:
Hi All, Can anyone tell me,is it possible to create an exe or msi for sql stored procedures,tables and triggers?I want to deploy the database objects(stored proc,tables,views and functions) as an...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.