以程式設計方式建立應用程式和 SQL Server - TopicsExpress



          

以程式設計方式建立應用程式和 SQL Server 資料庫間的連接 // C# public void ConnectToSql () { System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection (); // TODO: Modify the connection string and include any // additional required properties for your database. conn.ConnectionString = "integrated security=SSPI;data source=SQL Server Name;" + "persist security info=False;initial catalog=northwind"; try { conn.Open(); // Insert code to process data. } catch (Exception ex) { MessageBox.Show("Failed to connect to data source"); } finally { conn.Close(); } }
Posted on: Sat, 13 Jul 2013 12:53:02 +0000

Trending Topics



Recently Viewed Topics




© 2015