參考引用:Get connection string from app.config file
---
參考 ConfigurationManager
引入 System.Configuration
Private cn As New SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("StorkConnection").ConnectionString)
...
app.config
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"providerName="System.Data.SqlClient"/>
沒有留言:
張貼留言