Read about Compiler Error CS0236. If str and con are both instance fields of a class, you can't use str to initialize con like that.
gusano79
Practically a Master Poster
666 posts since May 2004
Reputation Points: 193
Solved Threads: 107
Skill Endorsements: 6
Make your "str" variable as static.
static string str = ConfigurationManager.ConnectionStrings["Bank"].ConnectionString;
SqlConnection con = new SqlConnection(str);
Mitja Bonca
Posting Maven
2,561 posts since May 2009
Reputation Points: 642
Solved Threads: 486
Skill Endorsements: 13