我的問題是我創建了一個SQL Server數據庫,但我只能從我自己的計算機上本地訪問它。我想要做的是將應用程序連接到服務器,並保存所有數據。如何使用C#中的IP地址將應用程序連接到SQL Server?
我用來連接到SQL Server數據庫的代碼是:
SqlConnection con = new SqlConnection(@"Data Source=(localdb)\v11.0;AttachDbFilename=C:\Users\donca\Desktop\Memo\Memo\ContNou.mdf;Integrated Security=True");
SqlCommand cmd1 = new SqlCommand("SELECT * FROM [dbo].[Cont] WHERE Nume_utilizator = @Nume_utilizator and Parola = @Parola;", con);
cmd1.Parameters.AddWithValue("@Nume_utilizator", this.Nume_utilizator.Text);
cmd1.Parameters.AddWithValue("@Parola", this.Parola.Text);
cmd1.Connection = con;
con.Open();
我的問題是:我怎樣才能改變這種從一個SQL Server連接和訪問數據和保存數據呢?
請參閱:https://www.connectionstrings.com/sql-server/ –