Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 15th, 2007, 09:20 AM
Authorized User
 
Join Date: Jul 2007
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data base connectivity

hello everyone,
  I am using Visual studio 2005 VC# windows application, Operating system is windows 2000 professional and database is sql server 2005.
I am unable to connect to database.What might be the problem
  thnks in advance
 
Old July 15th, 2007, 03:23 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi watashi,

The problem might be that you're not given us enough information.

There could be loads of reasons. Is your SQL Server machine turned on?? Did you actually install SQL Server? Does the box have a network connection?

I am only joking but I hope you see my point. Provide more information; tell us about your setup, tell us how you connect, describe the problem in more detail, post an error message and so on...

Then we might be able to suggest something useful.

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old July 16th, 2007, 06:24 AM
Authorized User
 
Join Date: Jul 2007
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello everyone,

really sorry for previous uncleared question.
I am using Visual studio 2005 , C# and OS is windows 2005 professional for a windows application. Data base is SQL SERVER 2005.
  I am unable to connect to the database . if i try "Add connection" and select "Microbase sql server database files browse to the .mdf file and " TEST CONNECTION". "Unable to open ............................ file . another process is using the file" message displays.

  I have created the database and tables and fill some values.mdf files are also existed.When i open the "Server Explorer" window ,No databases are found only "Data Connection" is visible.(My doubt is ,is it the problem with Windows 2000 professional because i hv never faced such problem with my pc with XP)
 Thanks in advance
WATASHI




 
Old July 16th, 2007, 01:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi watashi,

You may want to take a look here:

http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=395

The error you are describing seems to suggest you're trying to connect to the from within Visual Studio, right? If that's the case, and your SQL Server is *not* SQL Express, this won't work.

Instead, attach the .mdf file to your SQL Server instance, and then connect to it using a proper connection string.

HtH,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old July 17th, 2007, 02:11 AM
Authorized User
 
Join Date: Jul 2007
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

     Iam using SQL server 2005.How to attach the .mdf file to my SQL server.
   the connection string iam using is
   string strConnection = "Data Source=.\\SQLExpress;Integrated Security=true;AttachDbFilename=C:\\Program Files\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\Data\\master.mdf;User Instance=true;";

  But the result is same.
  I have created the table using microsoft SQL sever management studio express.I only need to open the connection and read the file.
If you know where to download SQL express instead of sql server, please let me know.
 Thanks a lot.

watashi

 
Old July 17th, 2007, 02:15 AM
Authorized User
 
Join Date: Jul 2007
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The error message is as follows
An attempt to attach an auto-named database for file C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\dbSensor1.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

  I tried to attach as follows Open SQL Server Management Studio and attach the .mdf file manually to the SQL Server. (Select the 'Databases' node, Right click and select 'Attach')
but result is same above message repeats. so is it a problem with UNC share because i m using windows 2000 professional.

with regards,
watashi
 
Old July 17th, 2007, 12:22 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Why are you attaching or even using the Master database?

This database is used and managed by SQL Server. You shouldn't use it for your own applications and instead create a fresh database.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old July 17th, 2007, 07:17 PM
Registered User
 
Join Date: Jul 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to asdf4525qd
Default

Hello Watashi
Do you look at the msdn? There are many ways to connect the database
include the SQL Server.

 
Old July 18th, 2007, 08:05 PM
Authorized User
 
Join Date: Jul 2007
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot
  i am now using oledb data connection instead of sql.Now able to connect to database.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Base Error anees ASP.NET 1.0 and 1.1 Professional 6 May 27th, 2008 09:02 AM
Data base Format virus220 ASP.NET 2.0 Professional 0 August 10th, 2007 09:37 AM
Data Connectivity Ned Flash (all versions) 4 March 30th, 2007 08:15 PM
Paging and Data base connectivity nicesukhi ASP.NET 2.0 Basics 1 August 2nd, 2006 09:33 AM
Transfering data from csv file to data base g_vamsi_krish ASP.NET 1.0 and 1.1 Professional 2 May 16th, 2006 11:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.