I will try to explain this clearly, so now I got
sqlConnection conn = new SqlConnection();
InitializeComponent();
conn.ConnectionString = "Data Source=servername;" +
"Initial Catalog=database;" +
"Integrated Security=True;";
in the MainWindow and I want to fire the command
SqlCommand scom = new SqlCommand(query, conn);
when a button is clicked, it's a stupid question now the button can't see conn because it's in the MainWindow how can I access it?
The thing is I don't want to reconfigure the connection every time the button is clicked.
connso we can't tell if it is in scope or not, but your description impliesconnis decleared at the class (window) level so why can't the button event "see" it? Is the button on a different window?