0

テキストボックスの接続値を使用して SQL Server データベースに接続するアプリケーションを作成しようとしていますが、接続しようとすると接続エラーが発生します

エラー コード: 40 - SQL サーバーへの接続を開けませんでした

アプリケーションのソースは次のとおりです。

private void ConnectToSQL() {
   string connectionString = @"Data Source=" + textBox4.Text + "Initial Catalog=" + textBox1.Text +"User ID=" + textBox2.Text + "Password=" + textBox3.Text;
using (SqlConnection objSqlConnection = new SqlConnection(connectionString)) {
    try {
        objSqlConnection.Open();
        objSqlConnection.Close();
        MessageBox.Show("Connection is successfull");
    } catch (Exception ex) {
        MessageBox.Show("Error : " + ex.Message.ToString());
    }

この問題で私を助けてください。

ありがとうございました!

4

2 に答える 2