Glx.Mzf
پنج شنبه 01 مهر 1389, 19:29 عصر
سلام دوستان
از دیتا بیسم Backup می گیرم بعدشم Restore می کنم
تا اینجا مشکلی نیست!
وقتی می خوام با بانکم کار کنم این Exception رو میده:
System.Data.SqlClient.SqlException was unhandled
Message="A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)"
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=20
LineNumber=0
Number=233
Server=".\\sqlexpress"
State=0
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.WriteSn i()
at System.Data.SqlClient.TdsParserStateObject.WritePa cket(Byte flushMode)
at System.Data.SqlClient.TdsParserStateObject.Execute Flush()
at System.Data.SqlClient.TdsParser.TdsExecuteSQLBatch (String text, Int32 timeout, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataRead er(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbComman d.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at TelephoneBook.TelBook.txtSearch_Click(Object sender, EventArgs e) in E:\New TelephoneBook\TelephoneBook\TelBook.cs:line 355
at System.Windows.Forms.Control.OnTextChanged(EventAr gs e)
at System.Windows.Forms.TextBoxBase.OnTextChanged(Eve ntArgs e)
at System.Windows.Forms.TextBoxBase.WmReflectCommand( Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessa ge(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInterna l(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TelephoneBook.Program.Main() in E:\New TelephoneBook\TelephoneBook\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAss embly()
at System.Runtime.Hosting.ApplicationActivator.Create Instance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.Create Instance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
این هم کدهای Backup و Restore
privatevoid button1_Click_2(object sender, EventArgs e)
{
try
{
SaveFileDialog saveFileDialog = newSaveFileDialog();
saveFileDialog.AddExtension = true;
saveFileDialog.CheckFileExists = false;
saveFileDialog.CheckPathExists = true;
saveFileDialog.OverwritePrompt = true;
saveFileDialog.FileName = "Backup";
saveFileDialog.Filter = "Backup File (*.Bak)|*.Bak";
saveFileDialog.DefaultExt = "Bak";
saveFileDialog.RestoreDirectory = true;
saveFileDialog.InitialDirectory = "C:\\";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
SqlCommand sqlCommand = newSqlCommand();
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandText = "BACKUP DATABASE Montazeri_AbbasAbad TO DISK = @Destination";
sqlCommand.Parameters.Add("@Destination", SqlDbType.VarChar);
sqlCommand.Parameters["@Destination"].Value = saveFileDialog.FileName;
sqlConnection.Open();
sqlCommand.ExecuteNonQuery();
MessageBox.Show(" ");
}
}
catch (Exception)
{
MessageBox.Show(" ");
}
finally
{
sqlConnection.Close();
}
}
privatevoid button3_Click_2(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = newOpenFileDialog();
openFileDialog1.ShowDialog();
if ((openFileDialog1.FileName != "") && (openFileDialog1.FileName != "openFileDialog1"))
{
try
{
string filename = openFileDialog1.FileName;
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandText = "ALTER DATABASE montazeri_AbbasAbad SET SINGLE_USER WITH ROLLBACK IMMEDIATE USE master;"
+ " RESTORE DATABASE montazeri_AbbasAbad FROM DISK =N'" + filename + "'";
sqlCommand.Connection = sqlConnection;
sqlConnection.Open();
sqlCommand.ExecuteNonQuery();
MessageBox.Show(" ");
}
catch
{
MessageBox.Show(" ");
}
finally
{
sqlConnection.Close();
}
}
}
اینو بگم اطلاعات درست بازیابی میشن
اگه دقیقا پس از بازگردانی اطلاعات برنامه رو reStart کنم مشکلی پیش نمی یاد
لطفا راهنماییم کنید
از دیتا بیسم Backup می گیرم بعدشم Restore می کنم
تا اینجا مشکلی نیست!
وقتی می خوام با بانکم کار کنم این Exception رو میده:
System.Data.SqlClient.SqlException was unhandled
Message="A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)"
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=20
LineNumber=0
Number=233
Server=".\\sqlexpress"
State=0
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.WriteSn i()
at System.Data.SqlClient.TdsParserStateObject.WritePa cket(Byte flushMode)
at System.Data.SqlClient.TdsParserStateObject.Execute Flush()
at System.Data.SqlClient.TdsParser.TdsExecuteSQLBatch (String text, Int32 timeout, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataRead er(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbComman d.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at TelephoneBook.TelBook.txtSearch_Click(Object sender, EventArgs e) in E:\New TelephoneBook\TelephoneBook\TelBook.cs:line 355
at System.Windows.Forms.Control.OnTextChanged(EventAr gs e)
at System.Windows.Forms.TextBoxBase.OnTextChanged(Eve ntArgs e)
at System.Windows.Forms.TextBoxBase.WmReflectCommand( Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessa ge(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInterna l(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindo wProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Messa ge& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TelephoneBook.Program.Main() in E:\New TelephoneBook\TelephoneBook\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAss embly()
at System.Runtime.Hosting.ApplicationActivator.Create Instance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.Create Instance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
این هم کدهای Backup و Restore
privatevoid button1_Click_2(object sender, EventArgs e)
{
try
{
SaveFileDialog saveFileDialog = newSaveFileDialog();
saveFileDialog.AddExtension = true;
saveFileDialog.CheckFileExists = false;
saveFileDialog.CheckPathExists = true;
saveFileDialog.OverwritePrompt = true;
saveFileDialog.FileName = "Backup";
saveFileDialog.Filter = "Backup File (*.Bak)|*.Bak";
saveFileDialog.DefaultExt = "Bak";
saveFileDialog.RestoreDirectory = true;
saveFileDialog.InitialDirectory = "C:\\";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
SqlCommand sqlCommand = newSqlCommand();
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandText = "BACKUP DATABASE Montazeri_AbbasAbad TO DISK = @Destination";
sqlCommand.Parameters.Add("@Destination", SqlDbType.VarChar);
sqlCommand.Parameters["@Destination"].Value = saveFileDialog.FileName;
sqlConnection.Open();
sqlCommand.ExecuteNonQuery();
MessageBox.Show(" ");
}
}
catch (Exception)
{
MessageBox.Show(" ");
}
finally
{
sqlConnection.Close();
}
}
privatevoid button3_Click_2(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = newOpenFileDialog();
openFileDialog1.ShowDialog();
if ((openFileDialog1.FileName != "") && (openFileDialog1.FileName != "openFileDialog1"))
{
try
{
string filename = openFileDialog1.FileName;
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandText = "ALTER DATABASE montazeri_AbbasAbad SET SINGLE_USER WITH ROLLBACK IMMEDIATE USE master;"
+ " RESTORE DATABASE montazeri_AbbasAbad FROM DISK =N'" + filename + "'";
sqlCommand.Connection = sqlConnection;
sqlConnection.Open();
sqlCommand.ExecuteNonQuery();
MessageBox.Show(" ");
}
catch
{
MessageBox.Show(" ");
}
finally
{
sqlConnection.Close();
}
}
}
اینو بگم اطلاعات درست بازیابی میشن
اگه دقیقا پس از بازگردانی اطلاعات برنامه رو reStart کنم مشکلی پیش نمی یاد
لطفا راهنماییم کنید