I have maintained a database dbo.Devices that stores information about paired Bluetooth Devices. I have attached the database file image . I have also created a combo box cmb_UsersDisplay that displays the list of Devices that is stored in the database. Now I want to store the Folder_Path of the device name that i select from the combo box cmb_UsersDisplay in a variable and display it on the console. I have tried to execute it using the below code, but the string displays the command not the the Folder path from the database for the device name I have selected from the combo box. For example: If I select a device name Moto E4 plus from the combo box and its folder path is stored in the database ,then it must display the Folder path associated with that device name on the console.
string selected_item = this.cmb_UsersDisplay.GetI
SqlConnection con = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\HP\Documents\Visu
al Studio 2015\Projects\Folder_Secur
mdf; Integrated Security = True");
string Sql = "select File_Path from dbo.Devices where DeviceName=selected_item";
SqlCommand cmd = new SqlCommand(Sql, con);