-1

こんにちは私はまだこのエラーが発生していて、別の解決策を試しましたが、うまくいきません!これが私のコードです

私はこのようにapp.configファイルに接続文字列を入れました:

<connectionStrings>
<add name="ComputerManagement" 
connectionString= "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=.. ; Integrated Security=false"/>

フォームのbutton_clickに次のコードを入力します。

  try
        {
            OleDbConnection conn = new OleDbConnection(GetConnectionString());
            OleDbCommand command = new OleDbCommand();
            command.CommandType = CommandType.Text;

            command.CommandText = "INSERT INTO Clients(C_name,C_phone ,C_mob ,C_add , C_email ,C_account) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4 + "','" + textBox5.Text + "','" + textBox6.Text + "')";
            command.Connection = conn;
            conn.Open();
            command.ExecuteNonQuery();
            conn.Close();
        }
        catch (Exception) { throw; }
4

1 に答える 1

0

あなたはあなたの声明で逃し.TexttextBox4

また、次のような接続オブジェクトからコマンドを作成する必要があります。

OleDbCommand command = conn.CreateCommand();

あなたのコードコマンドでは、接続について何も知りません。

于 2013-02-19T13:52:52.250 に答える