Um. Look at your code:
string str;
SqlConnection cnn;
str = @"server=(local);database=SMS_Data;Integrated Security=SSPI";
SqlConnection cnn = new SqlConnection(connetionString);
What is in
connetionString
? Because the variable you put your actual string into is called
str
...
You shouldn't "hard code" connection strings: it means you app has to be changed to switch between dev and production if nothing else, and that's dangerous. It also leads to loads of different places to change when you do release the product. Use a config file or similar instead. This is how I do it (but it's probably overkill for you):
Instance Storage - A Simple Way to Share Configuration Data among Applications[
^]