Showing posts with label sample. Show all posts
Showing posts with label sample. Show all posts

Thursday, March 29, 2012

Database in project

I'm using C#.Net 1.1 and i have a sample database inside my project (the actual database is in a folder in the project) and I simply want to connect tot the database inside the project and select and process data. i'm normally connecting to external databases so i'm kind of at a loss as to how i should connect to the database in the project (it's the Northwind Database and I'm using sql server 200).

any advice greatly appreciated.

In asp.net 2.0 you would add the database to the app_code folder

In asp.net 1.1 youll need to attach the db to sql server and query using a connection string.

Do you need help in attaching the db to sql server?

Cheers
Gregor

|||Yes, how do I attach the database to sql server?|||

Hi Myron

Do you have the database as an mdf file or do you have database scripts?

Cheers
Gregor

|||i have the database as an mdf file (Northwind.mdf)|||

The latest on this: in VS 2003 i went to Server Explorer to "Add Connection" . I am entering the following values (please not <addconnection> tags indicate start and end:

<ADDConnection>

Select or enter server name: (localhost)

Enter information to log onto server: chose "Use Windows NT integrated security)

Select the database on the server:

Attach a db file...: Northwind

Using the filename: C:\SQL Server 2000 Sample Databases\NORTHWND.MDF

</AddConnection>

But when i go to test the connection I am getting the following error:

<ERROR>

Test connection failed because of an error in initializing provider. [DBNETLIB].[ConnectionOpen (Connect()).]SqlServer does not exist or access denied.

</ERROR>

do you know that this means? the db exists so i now assume that I have to check the rights on the database...

Any help on this greatly appreciated

Friday, February 17, 2012

Database creation

I downloaded the sample database AdventureWorks from microsoft . When I run the download it created the data and log files under data folder in MSQLalong with other data and log files of master databases etc. However I do not see this database in SQLserver management studio. Can some one help me how to fix this so that I will be able to see this database in management studio.

I am downloading this for SQL server reporting purpose

Hi Kash,

The sample database installation delivers the database files to your machine, but does not "attach" the database to a specific SQL instance.

To attach the database you could do one of the following:

(1) Execute the following query:

USE master
GO
EXEC sp_attach_db 'AdventureWorksDW', '<path to your MDF file>AdventureWorksDW_Data.mdf', '<path to your LDF file>AdventureWorksDW_Log.ldf'

(you could use whatever name you like and also - make sure the MDF and LDF file names are correct, too)

(2) In SQL Management Studio, right-click the Databases folder, select "Attach". Navigate to the folder where the MDF file is installed and select it.

With either steps, the database is attached, recovered and comes online. BTW - this is a good way to move or rename a database: detach, move, attach (possibly under different name).

HTH,

Jivko Dobrev - MSFT
--
This posting is provided "AS IS" with no warranties, and confers no rights.