ASP.NETリンクデータベースの2つの構成
1024 ワード
Webを開くconfig
リンク方法①(推奨)
方法②CSでの使用:
リンク方法①(推奨)
リンク方法②
方法①CSでの使用: string str=System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
SqlConnection sqlstr = new SqlConnection(str);
またはstring str=System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
SqlConnection sqlstr = new SqlConnection(str);
方法②CSでの使用:
string str=System.Configuration.ConfigurationManager.appSettings["connStr"].ToString();
SqlConnection sqlstr = new SqlConnection(str);