欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Winform加入MS SQL连线字串

程序员文章站 2022-05-03 13:16:46
...

Winform加入MS SQL连线字串

App.config中:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
    </startup>
  <connectionStrings>
    <!-- '*** 資料庫 連結字串*** -->
    <add name="DBcs"
       connectionString="Data Source=210.65.10.150;Initial Catalog=STSP;Persist Security Info=True;User ID=sa;Password=jsene2wsx#EDC"
       providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

连线字串:

Private Sub alarm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim Conn As SqlConnection = New SqlConnection
        Conn.ConnectionString = ConfigurationManager.ConnectionStrings("Dbcs").ConnectionString()
        Conn.Open()
 End Sub

加入连线字串之前须参照:
Winform加入MS SQL连线字串
文章翻译自:dotblogs