Error when trying to update a database.

I have this code:

Dim RowValues(2) As String

RowValues(0) = AdUser.Text

RowValues(1) = AdPass.Text

RowValues(2) = AdTimes.Text

UserPassDS.Users.Rows.Add(RowValues)

UsersTableAdapter.Update(UserPassDS.Users)

When I try to update (the last row), It says an error.

The error is:

System.Data.SqlClient.SqlException was unhandled
  Class=14
  ErrorCode=-2146232060
  LineNumber=65536
  Message="An attempt to attach an auto-named database for file E:\Program Files\Microsoft Visual Studio 8\Common7\IDE\DB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
  Number=15350
  Procedure=""
  Server="\\.\pipe\2B935C34-1B3B-4A\tsql\query"
  Source=".Net SqlClient Data Provider"
  State=1
  StackTrace:
       at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
       at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
       at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
       at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
       at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
       at WindowsControlLibrary1.UserPassTableAdapters.UsersTableAdapter.Update(UsersDataTable dataTable) in C:\Documents and Settings\GIL\My Documents\Visual Studio 2005\Projects\Register\Register\UserPass.Designer.vb:line 703
       at WindowsControlLibrary1.UserControl1.AdReg_Click(Object sender, EventArgs e) in C:\Documents and Settings\GIL\My Documents\Visual Studio 2005\Projects\Register\Register\UserControl1.vb:line 22
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.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.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Microsoft.VisualStudio.Tools.UserControlTestContainer.Main(String[] args)

 

What can I do to fix it



Answer this question

Error when trying to update a database.

  • Clint A Morgan

    Anyone ! ! Please! It's very importent!
  • salyok

    The SQL Server is working, and the error isn't leaving...

    What to do !

    Thanks.


  • Kamil Kovar

    You cannot use a Dataset like in your example. You have to your DataTable int parantheses.

    For example ;

    UserDataDS.Tables["Users"]

    I hope it helps.



  • DennisR

    The error is because the database can not attach itself to sqlexpress. I would make sure the sqlexpress service is running.


  • Error when trying to update a database.