Advertisement
imjyb1008work

use ConnectionStrings

Nov 17th, 2015
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. using System.Data.SqlClient;
  2.  
  3. //WinForm
  4. using System.Configuration;
  5. string winFormConnectString = ConfigurationManager.ConnectionStrings["Your DB Name"].ConnectionString;
  6.  
  7. //WebForm
  8. System.Web.Configuration;
  9. string webFormConnectString = WebConfigurationManager.ConnectionStrings["Your DB Name"].ConnectionString;
  10.  
  11. SqlConnection connection = new SqlConnection(winFormConnectString);
  12. //或是 SqlConnection connection = new SqlConnection(webFormConnectString);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement