Click here to Skip to main content
15,893,644 members
Home / Discussions / C#
   

C#

 
QuestionUnit test of Asynchronous Block not happening Pin
Ashfaque Hussain28-Oct-15 0:57
Ashfaque Hussain28-Oct-15 0:57 
AnswerRe: Unit test of Asynchronous Block not happening Pin
Dave Kreskowiak28-Oct-15 4:02
mveDave Kreskowiak28-Oct-15 4:02 
AnswerRe: Unit test of Asynchronous Block not happening Pin
Nicholas Marty28-Oct-15 5:02
professionalNicholas Marty28-Oct-15 5:02 
GeneralRe: Unit test of Asynchronous Block not happening Pin
Ashfaque Hussain28-Oct-15 21:52
Ashfaque Hussain28-Oct-15 21:52 
QuestionFonts Activated through Win32 API AddFontResource is not available on the WPF control where as it is available in Documents and various application Pin
Prem9527-Oct-15 23:14
Prem9527-Oct-15 23:14 
SuggestionRe: Fonts Activated through Win32 API AddFontResource is not available on the WPF control where as it is available in Documents and various application Pin
Richard MacCutchan27-Oct-15 23:35
mveRichard MacCutchan27-Oct-15 23:35 
AnswerRe: Fonts Activated through Win32 API AddFontResource is not available on the WPF control where as it is available in Documents and various application Pin
Gerry Schmitz28-Oct-15 6:35
mveGerry Schmitz28-Oct-15 6:35 
QuestionNot allowed to change the 'ConnectionString' property. The connection's current state is connecting. Why I am getting this error? Pin
Member 1200209527-Oct-15 20:09
Member 1200209527-Oct-15 20:09 
<connectionstrings>

<add name="CostAllocationEntities2"
="" connectionstring="Data Source=PC210090\SQLEXPRESS;initial catalog=testdb1;Persist Security Info=True;User ID=sa;Password=password1$" providername="System.Data.SqlClient">


SqlConnection conn;

public SqlConnection openconn()
{
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CostAllocationEntities2"].ConnectionString);
try
{
    if (conn.State == ConnectionState.Closed)
    {<br />
        conn.Open();
        return conn;
    }
}
catch (Exception ex)
{
    MessageBox.Show(ex.ToString(), "Failed to Connect with Database.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    return null;
}

return conn;

}

public void GetBackup(string strDBName)
{
if (string.IsNullOrEmpty(strDBName))
{
MessageBox.Show("Server Name & Database can not be Blank");
return;
}
else
{

string destinationPath = ConfigurationManager.AppSettings.Get("BackupDestinationPath");
    BackupDeviceItem deviceItem = new BackupDeviceItem(destinationPath, DeviceType.File);               

    ServerConnection connection = new ServerConnection(ConfigurationManager.ConnectionStrings["CostAllocationEntities2"].ConnectionString);

    Server sqlServer = new Server(connection); 
    Database db = sqlServer.Databases[strDBName];

    Backup bkpDBFull = new Backup();
    bkpDBFull.Action = BackupActionType.Database;
    bkpDBFull.Database = strDBName;<br />
    bkpDBFull.Devices.AddDevice(String.Format("{0}{1}-{2}.bak", destinationPath, strDBName, DateTime.Now.ToString("yyyy-MM-dd")), DeviceType.File);
    bkpDBFull.BackupSetName = strDBName + " Backup";
    bkpDBFull.BackupSetDescription = strDBName + "- Full Backup";
    bkpDBFull.ExpirationDate = DateTime.Today.AddDays(10);<br />
    bkpDBFull.Initialize = false;               

    bkpDBFull.SqlBackup(sqlServer);
    MessageBox.Show("Backup Done");
}

}

On this line

Database db = sqlServer.Databases[strDBName];
I get an error:

Not allowed to change the 'ConnectionString' property. The connection's current state is connecting."

-- modified 28-Oct-15 2:27am.
AnswerRe: Not allowed to change the 'ConnectionString' property. The connection's current state is connecting. Why I am getting this error? Pin
John Torjo27-Oct-15 21:55
professionalJohn Torjo27-Oct-15 21:55 
QuestionPlugin 'System.Reflection.TargetInvocationException' While Passing Event Pin
jappi8827-Oct-15 7:04
jappi8827-Oct-15 7:04 
AnswerRe: Plugin 'System.Reflection.TargetInvocationException' While Passing Event Pin
Eddy Vluggen27-Oct-15 7:48
professionalEddy Vluggen27-Oct-15 7:48 
GeneralRe: Plugin 'System.Reflection.TargetInvocationException' While Passing Event Pin
John Torjo27-Oct-15 10:59
professionalJohn Torjo27-Oct-15 10:59 
GeneralRe: Plugin 'System.Reflection.TargetInvocationException' While Passing Event Pin
Eddy Vluggen27-Oct-15 12:36
professionalEddy Vluggen27-Oct-15 12:36 
QuestionWhy my .NET application is crashing?! Pin
Jassim Rahma26-Oct-15 23:42
Jassim Rahma26-Oct-15 23:42 
AnswerRe: Why my .NET application is crashing?! Pin
Pete O'Hanlon27-Oct-15 0:00
mvePete O'Hanlon27-Oct-15 0:00 
AnswerRe: Why my .NET application is crashing?! Pin
John Torjo27-Oct-15 1:45
professionalJohn Torjo27-Oct-15 1:45 
AnswerRe: Why my .NET application is crashing?! Pin
Dave Kreskowiak27-Oct-15 2:29
mveDave Kreskowiak27-Oct-15 2:29 
QuestionWorking on multithreading application Pin
Member 1132358526-Oct-15 23:39
Member 1132358526-Oct-15 23:39 
AnswerRe: Working on multithreading application Pin
Daniel Pfeffer27-Oct-15 1:23
professionalDaniel Pfeffer27-Oct-15 1:23 
GeneralRe: Working on multithreading application Pin
BillWoodruff27-Oct-15 3:29
professionalBillWoodruff27-Oct-15 3:29 
GeneralRe: Working on multithreading application Pin
Daniel Pfeffer27-Oct-15 4:05
professionalDaniel Pfeffer27-Oct-15 4:05 
AnswerRe: Working on multithreading application Pin
Foothill27-Oct-15 4:30
professionalFoothill27-Oct-15 4:30 
AnswerRe: Working on multithreading application Pin
Gerry Schmitz27-Oct-15 7:23
mveGerry Schmitz27-Oct-15 7:23 
Questionnew to C# Pin
Member 1206164726-Oct-15 18:39
Member 1206164726-Oct-15 18:39 
AnswerRe: new to C# Pin
Garth J Lancaster26-Oct-15 19:34
professionalGarth J Lancaster26-Oct-15 19:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.