SqlCommand command = new SqlCommand(sqlcmnd, con) string sqlcmnd = database TO DISK ='" + txtadd.Text + "\\" + "database" + "-" + ("yyyy-MM-dd-HH-mm-ss") + ".bak'" I was able to create the backup when database was connected with SSMS but when I moved the database to localDB now it's giving the error. I can login to the app after verifying the credentials with database Make sure that the name is entered correctly.īACKUP DATABASE is terminating abnormally. : Database 'IEC_database' does not exist. SqlConnection con = new Source = (localdb)\MSSQLLocalDB AttachDbFilename=" + path + + databaseName + " Integrated Security = True") Static string path = Path.GetFullPath(Environment.CurrentDirectory) ThanksĬonnection string: static string databaseName = "IEC_database.mdf" I am not able to make it work, your help would be appreciated.
The code is private void button_datecheck_Click(object sender, EventArgs e) I'm running a PowerShell script in a C# code and need to convert the output to a dictionary. I am stuck with a simple task and need community help, please. String macAdd = "MAC Address: " + theCurrentObject.ToString() ManagementObjectCollection theCollectionOfResults = theSearcher.Get() įoreach (ManagementObject theCurrentObject in theCollectionOfResults) ManagementObjectSearcher theSearcher = new ManagementObjectSearcher(theScope, theQuery) ObjectQuery theQuery = new ObjectQuery(theQueryBuilder.ToString()) TheQueryBuilder.Append("SELECT MACAddress FROM Win32_NetworkAdapter") StringBuilder theQueryBuilder = new StringBuilder() GetAllNetworkInterfaces() Īnd iterate through each interface, getting the MAC address for each one.Īnother way would be to use management object: ManagementScope theScope = new ManagementScope("\\\\computerName\\root\\cimv2") MacAddresses += nic.GetPhysicalAddress().ToString()
If (nic.OperationalStatus = OperationalStatus.Up) public string FetchMacId()įoreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())