Someone please help! I keep geting this error when trying to use sql

Someone please help! I keep geting this error when trying to use sql in my program. I don't know what to do and it always shows up when I am using sql in my program. Why?

An attempt to attach an auto-named database for file C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\CID.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at CCPDNS.CIDDataSetTableAdapters.CIDTableAdapter.Fill(CIDDataTable dataTable) in C:\Documents and Settings\All Users\Documents\Visual Studio 2005\Projects\CCPD Project\CCPD Project\CIDDataSet.Designer.vb:line 1544
at CCPDNS.DesktopUC.DesktopUC_VisibleChanged(Object sender, EventArgs e) in C:\Documents and Settings\All Users\Documents\Visual Studio 2005\Projects\CCPD Project\CCPD Project\DesktopUC.vb:line 16
at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.ScrollableControl.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Design.ControlDesigner.SetUnhandledException(Control owner, Exception exception)
at System.Windows.Forms.Design.ControlDesigner.DesignerWindowTarget.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SetParent(HandleRef hWnd, HandleRef hWndParent)
at System.Windows.Forms.Control.SetParentHandle(IntPtr value)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Design.DesignerFrame.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Design.PbrsForward.System.Windows.Forms.IWindowTarget.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
at System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.get_ShowKeyboardCues()
at System.Windows.Forms.ControlPaint.CreateTextFormatFlags(Control ctl, ContentAlignment textAlign, Boolean showEllipsis, Boolean useMnemonic)
at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.CreateTextFormatFlags()
at System.Windows.Forms.ButtonBase.CreateTextFormatFlags()
at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.CommonLayout()
at System.Windows.Forms.ButtonInternal.CheckableControlBaseAdapter.CommonLayout()
at System.Windows.Forms.ButtonInternal.RadioButtonBaseAdapter.CommonLayout()
at System.Windows.Forms.ButtonInternal.RadioButtonStandardAdapter.Layout(PaintEventArgs e)
at System.Windows.Forms.ButtonInternal.CheckableControlBaseAdapter.GetPreferredSizeCore(Size proposedSize)
at System.Windows.Forms.ButtonBase.GetPreferredSizeCore(Size proposedConstraints)
at System.Windows.Forms.RadioButton.GetPreferredSizeCore(Size proposedConstraints)
at System.Windows.Forms.Control.GetPreferredSize(Size proposedSize)
at System.Windows.Forms.ButtonBase.GetPreferredSize(Size proposedSize)
at System.Windows.Forms.Layout.DefaultLayout.LayoutAutoSizedControls(IArrangedElement container)
at System.Windows.Forms.Layout.DefaultLayout.xLayout(IArrangedElement container, Boolean measureOnly, Size& preferredSize)
at System.Windows.Forms.Layout.DefaultLayout.LayoutCore(IArrangedElement container, LayoutEventArgs args)
at System.Windows.Forms.Layout.LayoutEngine.Layout(Object container, LayoutEventArgs layoutEventArgs)
at System.Windows.Forms.Control.OnLayout(LayoutEventArgs levent)
at System.Windows.Forms.ScrollableControl.OnLayout(LayoutEventArgs levent)
at System.Windows.Forms.ContainerControl.OnLayout(LayoutEventArgs e)
at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
at System.Windows.Forms.Control.PerformLayout()
at System.Windows.Forms.Control.ResumeLayout(Boolean performLayout)
at System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager manager, String name, CodeStatementCollection statements)

[6276 byte] By [TheQuietShadow] at [2007-12-24]
# 1

as it states, the database may have already been attached or not found

Can you post the code on where this is happening from? (the connection string etc...)

When does this happen? during code execution or somewhere else?

ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
I don't know, thats the problem. I was also having the same problem with my last program, so i decided to rebuild it from scratch. This is where I'm at now.
TheQuietShadow at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
when does it happen? When you load the project? when you run the project? Using Visual Basic.NET or VBExpress edition?
ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4

Oh, every time I open my first form(Form1).

TheQuietShadow at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5
The

.mdf file must be available on a local drive for the SQL server

instance. This will fail as indicated if the SQL server instance

you are using is installed on another PC.

Odd location for the .mdf file BTW. Avoid using the VS2005 installation directories...

nobugz at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 6
but it is on this computer, and its even included in this project.
TheQuietShadow at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 7
I can send a copy of my project to anyone that can help.
TheQuietShadow at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 8

I agree that db does look to be in an odd place. So odd in fact that I refuse to believe it's there :) I think your connection string may be wrong for some reason. For one the DB is most probably in the same folder as your project, not in the VS install folder. For two it's very odd that your project files should be under the "All Users" profile.

You have some strange habits in project storage, my friend. As for already being attached (I may be wrong) but if the VS server explorer is being used to browse the tables and such of the DB then the DB must already be attached, no? make sure your server explorer connection is closed maybe? and DEFINATELY verify that connection string.

AnthonyD.Green at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 9
Thanks for helping, but I'm a nubie, I don't quite understand what you are telling me.
TheQuietShadow at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 10

I said a lot, what in specific didn't you understand? If none of it in the least your problems are much larger than you suspect.

I said that the file paths you mentioned in your post look like hogwash... they don't make sense or look like a reasonable location to find what you're looking for. Remove the DB from the project and then add it again, I think VS thinks your DB is somewhere it physically isn't or shouldn't be. So basically discard any potentially erroneous code and configuration pertaining to the DB and start again.

Somewhere in your project source (more likely config settings) there is a connection string being used by your DataAdapter to Fill your DataSet. Verify that the connection string is accurately describing the location of the DB file. If you don't understand DB connection strings go look it up.

AnthonyD.Green at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...