Tag - C++

How to get Active Directory connection string in C#.NET

First you will have to add a reference for System.DirectoryServicesYou must run the application on a machine within the same domain to be able to connect to the Active Directoryusing System.DirectoryServices;private string GetActiveDirectoryConnectionString() { DirectoryEntry root = new DirectoryEntry("LDAP://RootDSE"); using (root) { string dnc = root.Properties["defaultNamingContext"][0].ToString(); ...

How to add windows forms control in WPF

I will describe how we can use windows forms controls in WPF application.I'll assume I have a WPF Application and I want to use DateTimePicker Control, how I can do that in WPF Application?1- Create WPF Application.2- Add Stackpanel control.3- in Solution Explorer Add Reference for:System.Windows.FormsWindowsFormsIntegrationusing WindowsControls = System.Windows.Forms; using WindowsIntegration...

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack ASP.NET

While I was debugging an ASP.NET Application, I wanted to get an object values I got this error message instead:"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack"This problem occurs when using Response.Redirect or Server.Transfer method, because the Response.End method...

How to programmatically create iFrame in ASP.NET

Sometimes we may need to create iFrames and use it within GridView or Repeater, and we want to pass some values to it.This example will show you how to create iFrame Programmatically and add it to a PlaceHolder.HtmlGenericControl myFrame = new HtmlGenericControl();myFrame.TagName = "IFRAME"; myFrame.Attributes["src"] = "MyPagePath"; myFrame.Attributes["id"] = "myFrame1"; myFrame.Attributes["name"] = "myFrame1"; myFrame.Attributes["width"] =...

How to convert SqlDataSource to DataTable and DataView in C#.NET

Sometimes I want to use SqlDataSource  returned data programmatically and here is how you can do this,In this example I will assume that SqlDataSource  ID is SqlDataSource1 which is the default ID:DataSourceSelectArguments args = new DataSourceSelectArguments(); DataView view = SqlDataSource1.Select(args) as DataView; DataTable dt = view.ToTable();

How to check SQL Server database is exists using C#.NET

The following method using sys. schema and views such as sys.databases and sys.tables.As we know that the old style sysobjects and sysdatabases and those catalog views have been deprecated since SQL Server.private static bool CheckDatabaseExists(string connectionString, string databaseName) { string sqlQuery; bool result = false; try ...